*** empty log message ***
[gnus] / lisp / dgnushack.el
1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994,95,96,97,98,99 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Version: 4.19
6 ;; Keywords: news, path
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (fset 'facep 'ignore)
30
31 (require 'cl)
32
33 ;; If we are building w3 in a different directory than the source
34 ;; directory, we must read *.el from source directory and write *.elc
35 ;; into the building directory.  For that, we define this function
36 ;; before loading bytecomp.  Bytecomp doesn't overwrite this function.
37 (defun byte-compile-dest-file (filename)
38   "Convert an Emacs Lisp source file name to a compiled file name.
39  In addition, remove directory name part from FILENAME."
40   (setq filename (byte-compiler-base-file-name filename))
41   (setq filename (file-name-sans-versions filename))
42   (setq filename (file-name-nondirectory filename))
43   (if (memq system-type '(win32 w32 mswindows windows-nt))
44       (setq filename (downcase filename)))
45   (cond ((eq system-type 'vax-vms)
46         (concat (substring filename 0 (string-match ";" filename)) "c"))
47        ((string-match emacs-lisp-file-regexp filename)
48         (concat (substring filename 0 (match-beginning 0)) ".elc"))
49        (t (concat filename ".elc"))))
50
51 (require 'bytecomp)
52
53 (defvar srcdir (or (getenv "srcdir") "."))
54
55 (push srcdir load-path)
56 (load (expand-file-name "lpath.el" srcdir) nil t)
57
58 (defalias 'device-sound-enabled-p 'ignore)
59 (defalias 'play-sound-file 'ignore)
60 (defalias 'nndb-request-article 'ignore)
61 (defalias 'efs-re-read-dir 'ignore)
62 (defalias 'ange-ftp-re-read-dir 'ignore)
63 (defalias 'define-mail-user-agent 'ignore)
64
65 (eval-and-compile
66   (unless (string-match "XEmacs" emacs-version)
67     (fset 'get-popup-menu-response 'ignore)
68     (fset 'event-object 'ignore)
69     (fset 'x-defined-colors 'ignore)
70     (fset 'read-color 'ignore)))
71
72 (defun dgnushack-compile (&optional warn)
73   ;;(setq byte-compile-dynamic t)
74   (unless warn
75     (setq byte-compile-warnings
76           '(free-vars unresolved callargs redefine)))
77   (unless (locate-library "cus-edit")
78     (error "You do not seem to have Custom installed.
79 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
80 You also then need to add the following to the lisp/dgnushack.el file:
81
82      (push \"~/lisp/custom\" load-path)
83
84 Modify to suit your needs."))
85   (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
86         (xemacs (string-match "XEmacs" emacs-version))
87         ;;(byte-compile-generate-call-tree t)
88         file elc)
89     (condition-case ()
90         (require 'w3-forms)
91       (error
92        (dolist (file '("nnweb.el" "nnlistserv.el" "nnultimate.el"
93                        "nnslashdot.el" "nnwarchive.el" "webmail.el"))
94          (setq files (delete file files)))))
95     (while (setq file (pop files))
96       (setq file (expand-file-name file srcdir))
97       (when (or (and (not xemacs)
98                      (not (member (file-name-nondirectory file)
99                                   '("gnus-xmas.el" "gnus-picon.el"
100                                     "messagexmas.el" "nnheaderxm.el"
101                                     "smiley.el" "x-overlay.el"))))
102                 (and xemacs
103                      (not (member file '("md5.el")))))
104         (when (or (not (file-exists-p (setq elc (concat file "c"))))
105                   (file-newer-than-file-p file elc))
106           (ignore-errors
107             (byte-compile-file file)))))))
108
109 (defun dgnushack-recompile ()
110   (require 'gnus)
111   (byte-recompile-directory "." 0))
112
113 ;;; dgnushack.el ends here
114