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 last (&whole form x &optional n)
53 (if (and (fboundp 'last)
54 (subrp (symbol-function 'last)))
70 (while (consp (cdr x))
74 (define-compiler-macro coerce (&whole form x type)
75 (if (and (fboundp 'coerce)
76 (subrp (symbol-function 'coerce)))
80 (cond ((eq type 'list) (if (listp x) x (append x nil)))
81 ((eq type 'vector) (if (vectorp x) x (vconcat x)))
82 ((eq type 'string) (if (stringp x) x (concat x)))
83 ((eq type 'array) (if (arrayp x) x (vconcat x)))
84 ((and (eq type 'character) (stringp x) (= (length x) 1))
86 ((and (eq type 'character) (symbolp x)
87 (= (length (symbol-name x)) 1))
88 (aref (symbol-name x) 0))
89 ((eq type 'float) (float x))
91 (t (error "Can't coerce %s to type %s" x type))))))
93 (define-compiler-macro merge (&whole form type seq1 seq2 pred &rest keys)
94 (if (and (fboundp 'merge)
95 (subrp (symbol-function 'merge)))
101 (or (listp seq1) (setq seq1 (append seq1 nil)))
102 (or (listp seq2) (setq seq2 (append seq2 nil)))
104 (while (and seq1 seq2)
105 (if (funcall pred (car seq2) (car seq1))
106 (push (pop seq2) res)
107 (push (pop seq1) res)))
108 (coerce (nconc (nreverse res) seq1 seq2) type)))))
110 (define-compiler-macro subseq (&whole form seq start &optional end)
111 (if (and (fboundp 'subseq)
112 (subrp (symbol-function 'subseq)))
119 (substring seq start end)
122 (setq end (+ end (setq len (length seq)))))
124 (setq start (+ start (or len (setq len (length seq))))))
127 (setq seq (nthcdr start seq)))
129 (while (>= (setq end (1- end)) start)
130 (push (pop seq) res))
133 (let ((res (make-vector (max (- end start) 0) nil))
136 (aset res i (aref seq start))
143 (substring seq start)
146 (setq start (+ start (or len (setq len (length seq))))))
149 (setq seq (nthcdr start seq)))
152 (let* ((end (or len (length seq)))
153 (res (make-vector (max (- end start) 0) nil))
156 (aset res i (aref seq start))
162 ;; If we are building w3 in a different directory than the source
163 ;; directory, we must read *.el from source directory and write *.elc
164 ;; into the building directory. For that, we define this function
165 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
166 (defun byte-compile-dest-file (filename)
167 "Convert an Emacs Lisp source file name to a compiled file name.
168 In addition, remove directory name part from FILENAME."
169 (setq filename (byte-compiler-base-file-name filename))
170 (setq filename (file-name-sans-versions filename))
171 (setq filename (file-name-nondirectory filename))
172 (if (memq system-type '(win32 w32 mswindows windows-nt))
173 (setq filename (downcase filename)))
174 (cond ((eq system-type 'vax-vms)
175 (concat (substring filename 0 (string-match ";" filename)) "c"))
176 ((string-match emacs-lisp-file-regexp filename)
177 (concat (substring filename 0 (match-beginning 0)) ".elc"))
178 (t (concat filename ".elc"))))
182 (push srcdir load-path)
183 (load (expand-file-name "lpath.el" srcdir) nil t)
185 (defalias 'device-sound-enabled-p 'ignore)
186 (defalias 'play-sound-file 'ignore)
187 (defalias 'nndb-request-article 'ignore)
188 (defalias 'efs-re-read-dir 'ignore)
189 (defalias 'ange-ftp-re-read-dir 'ignore)
190 (defalias 'define-mail-user-agent 'ignore)
193 (unless (featurep 'xemacs)
194 (defalias 'get-popup-menu-response 'ignore)
195 (defalias 'event-object 'ignore)
196 (defalias 'x-defined-colors 'ignore)
197 (defalias 'read-color 'ignore)))
199 (defun dgnushack-compile (&optional warn)
200 ;;(setq byte-compile-dynamic t)
202 (setq byte-compile-warnings
203 '(free-vars unresolved callargs redefine)))
204 (unless (locate-library "cus-edit")
205 (error "You do not seem to have Custom installed.
206 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
207 You also then need to add the following to the lisp/dgnushack.el file:
209 (push \"~/lisp/custom\" load-path)
211 Modify to suit your needs."))
212 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
213 ;;(byte-compile-generate-call-tree t)
215 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
217 (when (featurep 'xemacs)
218 (setq gnus-xmas-glyph-directory "dummy"))
219 (dolist (file '("dgnushack.el" "lpath.el"))
220 (setq files (delete file files)))
221 (when (featurep 'base64)
222 (setq files (delete "base64.el" files)))
226 (message "No w3: %s %s" code (locate-library "w3-forms"))
227 (dolist (file '("nnweb.el" "nnlistserv.el" "nnultimate.el"
228 "nnslashdot.el" "nnwarchive.el" "webmail.el"
229 "nnwfm.el" "nnrss.el"))
230 (setq files (delete file files)))))
232 (if (featurep 'xemacs)
233 '("md5.el" "smiley-ems.el")
234 '("gnus-xmas.el" "gnus-picon.el" "messagexmas.el"
235 "nnheaderxm.el" "smiley.el")))
236 (setq files (delete file files)))
239 (setq file (expand-file-name file srcdir))
240 (when (and (file-exists-p
241 (setq elc (concat (file-name-nondirectory file) "c")))
242 (file-newer-than-file-p file elc))
245 (while (setq file (pop files))
246 (setq file (expand-file-name file srcdir))
247 (when (or (not (file-exists-p
248 (setq elc (concat (file-name-nondirectory file) "c"))))
249 (file-newer-than-file-p file elc))
251 (byte-compile-file file))))))
253 (defun dgnushack-recompile ()
255 (byte-recompile-directory "." 0))
257 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el"))
258 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el"))
260 (defun dgnushack-make-cus-load ()
262 (let ((cusload-base-file dgnushack-cus-load-file))
263 (if (fboundp 'custom-make-dependencies)
264 (custom-make-dependencies)
265 (Custom-make-dependencies))))
267 (defun dgnushack-make-auto-load ()
269 (let ((generated-autoload-file dgnushack-gnus-load-file)
270 (make-backup-files nil)
271 (autoload-package-name "gnus"))
272 (if (featurep 'xemacs)
273 (if (file-exists-p generated-autoload-file)
274 (delete-file generated-autoload-file))
275 (with-temp-file generated-autoload-file
277 (batch-update-autoloads)))
279 (defun dgnushack-make-load ()
280 (message (format "Generating %s..." dgnushack-gnus-load-file))
281 (with-temp-file dgnushack-gnus-load-file
282 (insert-file-contents dgnushack-cus-load-file)
283 (delete-file dgnushack-cus-load-file)
284 (goto-char (point-min))
285 (search-forward ";;; Code:")
287 (delete-region (point-min) (point))
289 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
293 (goto-char (point-max))
294 (if (search-backward "custom-versions-load-alist" nil t)
297 (while (eq (char-after) ?\;)
300 (delete-region (point) (point-max))
302 ;; smiley-* are duplicated. Remove them all.
303 (let ((point (point)))
304 (insert-file-contents dgnushack-gnus-load-file)
306 (while (search-forward "smiley-" nil t)
308 (if (looking-at "(autoload ")
309 (delete-region (point) (progn (forward-sexp) (point)))
312 (goto-char (point-max))
313 (when (search-backward "\n(provide " nil t)
315 (delete-region (point) (point-max)))
318 \(provide 'gnus-load)
321 ;;; version-control: never
322 ;;; no-byte-compile: t
323 ;;; no-update-autoloads: t
325 ;;; gnus-load.el ends here\n"))
326 (message (format "Compiling %s..." dgnushack-gnus-load-file))
327 (byte-compile-file dgnushack-gnus-load-file))
329 ;;; dgnushack.el ends here