1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news, path
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (defalias 'facep 'ignore)
34 (defvar srcdir (or (getenv "srcdir") "."))
36 (defun my-getenv (str)
37 (let ((val (getenv str)))
38 (if (equal val "no") nil val)))
40 (if (my-getenv "lispdir")
41 (push (my-getenv "lispdir") load-path))
43 (push (or (my-getenv "URLDIR") (expand-file-name "../../url/lisp/" srcdir))
46 (push (or (my-getenv "W3DIR") (expand-file-name "../../w3/lisp/" srcdir))
49 ;(push "/usr/share/emacs/site-lisp" load-path)
51 (unless (featurep 'xemacs)
52 (define-compiler-macro merge (&whole form type seq1 seq2 pred &rest keys)
53 (if (and (fboundp 'merge)
54 (subrp (symbol-function 'merge)))
60 (or (listp seq1) (setq seq1 (append seq1 nil)))
61 (or (listp seq2) (setq seq2 (append seq2 nil)))
63 (while (and seq1 seq2)
64 (if (funcall pred (car seq2) (car seq1))
66 (push (pop seq1) res)))
67 (let ((x (nconc (nreverse res) seq1 seq2)))
68 (cond ((eq type 'list) (if (listp x) x (append x nil)))
69 ((eq type 'vector) (if (vectorp x) x (vconcat x)))
70 ((eq type 'string) (if (stringp x) x (concat x)))
71 ((eq type 'array) (if (arrayp x) x (vconcat x)))
72 ((and (eq type 'character) (stringp x) (= (length x) 1))
74 ((and (eq type 'character) (symbolp x))
75 (aref (symbol-name x) 0))
76 ((eq type 'float) (float x))
78 (t (error "Can't coerce %s to type %s" x type))))))))
80 (define-compiler-macro copy-list (&whole form list)
81 (if (and (fboundp 'copy-list)
82 (subrp (symbol-function 'copy-list)))
87 (while (consp list) (push (pop list) res))
88 (prog1 (nreverse res) (setcdr res list)))
91 (define-compiler-macro remove (&whole form item seq)
92 (if (>= emacs-major-version 21)
94 `(delete ,item (copy-sequence ,seq)))))
96 ;; If we are building w3 in a different directory than the source
97 ;; directory, we must read *.el from source directory and write *.elc
98 ;; into the building directory. For that, we define this function
99 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
100 (defun byte-compile-dest-file (filename)
101 "Convert an Emacs Lisp source file name to a compiled file name.
102 In addition, remove directory name part from FILENAME."
103 (setq filename (byte-compiler-base-file-name filename))
104 (setq filename (file-name-sans-versions filename))
105 (setq filename (file-name-nondirectory filename))
106 (if (memq system-type '(win32 w32 mswindows windows-nt))
107 (setq filename (downcase filename)))
108 (cond ((eq system-type 'vax-vms)
109 (concat (substring filename 0 (string-match ";" filename)) "c"))
110 ((string-match emacs-lisp-file-regexp filename)
111 (concat (substring filename 0 (match-beginning 0)) ".elc"))
112 (t (concat filename ".elc"))))
115 ;; To avoid having defsubsts and inlines happen.
116 ;(if (featurep 'xemacs)
117 ; (require 'byte-optimize)
118 ; (require 'byte-opt))
119 ;(defun byte-optimize-inline-handler (form)
120 ; "byte-optimize-handler for the `inline' special-form."
121 ; (cons 'progn (cdr form)))
122 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
124 (push srcdir load-path)
125 (load (expand-file-name "lpath.el" srcdir) nil t)
127 (defalias 'device-sound-enabled-p 'ignore)
128 (defalias 'play-sound-file 'ignore)
129 (defalias 'nndb-request-article 'ignore)
130 (defalias 'efs-re-read-dir 'ignore)
131 (defalias 'ange-ftp-re-read-dir 'ignore)
132 (defalias 'define-mail-user-agent 'ignore)
135 (unless (featurep 'xemacs)
136 (defalias 'get-popup-menu-response 'ignore)
137 (defalias 'event-object 'ignore)
138 (defalias 'x-defined-colors 'ignore)
139 (defalias 'read-color 'ignore)))
141 (defun dgnushack-compile (&optional warn)
142 ;;(setq byte-compile-dynamic t)
144 (setq byte-compile-warnings
145 '(free-vars unresolved callargs redefine)))
146 (unless (locate-library "cus-edit")
147 (error "You do not seem to have Custom installed.
148 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
149 You also then need to add the following to the lisp/dgnushack.el file:
151 (push \"~/lisp/custom\" load-path)
153 Modify to suit your needs."))
154 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
155 ;;(byte-compile-generate-call-tree t)
157 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
159 (when (featurep 'xemacs)
160 (setq gnus-xmas-glyph-directory "dummy"))
161 (dolist (file '("dgnushack.el" "lpath.el"))
162 (setq files (delete file files)))
163 (when (featurep 'base64)
164 (setq files (delete "base64.el" files)))
168 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
169 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
170 (setq files (delete file files)))))
174 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
175 (setq files (delete "gnus-mh.el" files))))
179 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
180 (setq files (delete "nnrss.el" files))))
182 (if (featurep 'xemacs)
184 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el")))
185 (setq files (delete file files)))
188 (setq file (expand-file-name file srcdir))
189 (when (and (file-exists-p
190 (setq elc (concat (file-name-nondirectory file) "c")))
191 (file-newer-than-file-p file elc))
194 (while (setq file (pop files))
195 (setq file (expand-file-name file srcdir))
196 (when (or (not (file-exists-p
197 (setq elc (concat (file-name-nondirectory file) "c"))))
198 (file-newer-than-file-p file elc))
200 (byte-compile-file file))))))
202 (defun dgnushack-recompile ()
204 (byte-recompile-directory "." 0))
206 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el"))
207 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el"))
209 (defun dgnushack-make-cus-load ()
211 (let ((cusload-base-file dgnushack-cus-load-file))
212 (if (fboundp 'custom-make-dependencies)
213 (custom-make-dependencies)
214 (Custom-make-dependencies))))
216 (defun dgnushack-make-auto-load ()
218 (unless (make-autoload '(define-derived-mode child parent name
221 (defadvice make-autoload (around handle-define-derived-mode activate)
222 "Handle `define-derived-mode'."
223 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
224 (setq ad-return-value
226 (list 'quote (nth 1 (ad-get-arg 0)))
228 (nth 4 (ad-get-arg 0))
231 (put 'define-derived-mode 'doc-string-elt 3))
232 (let ((generated-autoload-file dgnushack-gnus-load-file)
233 (make-backup-files nil)
234 (autoload-package-name "gnus"))
235 (if (featurep 'xemacs)
236 (if (file-exists-p generated-autoload-file)
237 (delete-file generated-autoload-file))
238 (with-temp-file generated-autoload-file
240 (batch-update-autoloads)))
242 (defun dgnushack-make-load ()
243 (message (format "Generating %s..." dgnushack-gnus-load-file))
244 (with-temp-file dgnushack-gnus-load-file
245 (insert-file-contents dgnushack-cus-load-file)
246 (delete-file dgnushack-cus-load-file)
247 (goto-char (point-min))
248 (search-forward ";;; Code:")
250 (delete-region (point-min) (point))
252 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
256 (goto-char (point-max))
257 (if (search-backward "custom-versions-load-alist" nil t)
260 (while (eq (char-after) ?\;)
263 (delete-region (point) (point-max))
265 ;; smiley-* are duplicated. Remove them all.
266 (let ((point (point)))
267 (insert-file-contents dgnushack-gnus-load-file)
269 (while (search-forward "smiley-" nil t)
271 (if (looking-at "(autoload ")
272 (delete-region (point) (progn (forward-sexp) (point)))
275 (goto-char (point-max))
276 (when (search-backward "\n(provide " nil t)
278 (delete-region (point) (point-max)))
281 \(provide 'gnus-load)
284 ;;; version-control: never
285 ;;; no-byte-compile: t
286 ;;; no-update-autoloads: t
288 ;;; gnus-load.el ends here
290 ;; Workaround the bug in some version of XEmacs.
291 (when (featurep 'xemacs)
295 (goto-char (point-min))
296 (when (and (fboundp 'custom-add-loads)
297 (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
298 (search-forward "\n;;; Code:" nil t)
300 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
301 (message (format "Compiling %s..." dgnushack-gnus-load-file))
302 (byte-compile-file dgnushack-gnus-load-file))
304 ;;; dgnushack.el ends here