1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003
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 ;; Define compiler macros for the functions provided by cl in old Emacsen.
52 (unless (featurep 'xemacs)
53 (define-compiler-macro butlast (&whole form x &optional n)
54 (if (>= emacs-major-version 21)
67 (setq x (copy-sequence x))
68 (setcdr (nthcdr (- (1- m) n) x) nil)))
74 (setq x (copy-sequence x))
75 (setcdr (nthcdr (- m 2) x) nil)
78 (define-compiler-macro remove (&whole form item seq)
79 (if (>= emacs-major-version 21)
81 `(delete ,item (copy-sequence ,seq))))
83 (define-compiler-macro mapc (&whole form fn seq &rest rest)
84 (if (>= emacs-major-version 21)
89 (args (list seq ,@rest))
90 (m (apply (function min) (mapcar (function length) args)))
93 (apply fn (mapcar (function (lambda (arg) (nth n arg))) args))
100 ;; If we are building w3 in a different directory than the source
101 ;; directory, we must read *.el from source directory and write *.elc
102 ;; into the building directory. For that, we define this function
103 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
104 (defun byte-compile-dest-file (filename)
105 "Convert an Emacs Lisp source file name to a compiled file name.
106 In addition, remove directory name part from FILENAME."
107 (setq filename (byte-compiler-base-file-name filename))
108 (setq filename (file-name-sans-versions filename))
109 (setq filename (file-name-nondirectory filename))
110 (if (memq system-type '(win32 w32 mswindows windows-nt))
111 (setq filename (downcase filename)))
112 (cond ((eq system-type 'vax-vms)
113 (concat (substring filename 0 (string-match ";" filename)) "c"))
114 ((string-match emacs-lisp-file-regexp filename)
115 (concat (substring filename 0 (match-beginning 0)) ".elc"))
116 (t (concat filename ".elc"))))
119 ;; To avoid having defsubsts and inlines happen.
120 ;(if (featurep 'xemacs)
121 ; (require 'byte-optimize)
122 ; (require 'byte-opt))
123 ;(defun byte-optimize-inline-handler (form)
124 ; "byte-optimize-handler for the `inline' special-form."
125 ; (cons 'progn (cdr form)))
126 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
128 (when (and (not (featurep 'xemacs))
129 (= emacs-major-version 21)
130 (= emacs-minor-version 3)
132 (let ((byte-compile-error-on-warn t))
133 (byte-optimize-form (quote (pop x)) t)
135 (error (string-match "called for effect"
136 (error-message-string code)))))
137 (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
140 "Silence the warning \"...called for effect\" for the `pop' form.
141 It is effective only when the `pop' macro is defined by cl.el rather
144 (if (and (eq (car-safe form) 'car)
146 (setq tmp (get 'car 'side-effect-free))
147 (not byte-compile-delete-errors)
148 (not (eq tmp 'error-free))
149 (eq (car-safe (cadr form)) 'prog1)
150 (let ((var (cadr (cadr form)))
151 (last (nth 2 (cadr form))))
153 (null (nthcdr 3 (cadr form)))
154 (eq (car-safe last) 'setq)
156 (eq (car-safe (nth 2 last)) 'cdr)
157 (eq (cadr (nth 2 last)) var))))
159 (put 'car 'side-effect-free 'error-free)
162 (put 'car 'side-effect-free tmp)))
165 (push srcdir load-path)
166 (load (expand-file-name "lpath.el" srcdir) nil t)
168 (defalias 'device-sound-enabled-p 'ignore)
169 (defalias 'play-sound-file 'ignore)
170 (defalias 'nndb-request-article 'ignore)
171 (defalias 'efs-re-read-dir 'ignore)
172 (defalias 'ange-ftp-re-read-dir 'ignore)
173 (defalias 'define-mail-user-agent 'ignore)
176 (unless (featurep 'xemacs)
177 (defalias 'get-popup-menu-response 'ignore)
178 (defalias 'event-object 'ignore)
179 (defalias 'x-defined-colors 'ignore)
180 (defalias 'read-color 'ignore)))
183 (when (featurep 'xemacs)
184 ;; XEmacs 21.1 needs some extra hand holding
185 (when (eq emacs-minor-version 1)
186 (autoload 'custom-declare-face "cus-face" nil t)
187 (autoload 'cl-compile-time-init "cl-macs" nil t)
188 (autoload 'defadvice "advice" nil nil 'macro))
189 (unless (fboundp 'defadvice)
190 (autoload 'defadvice "advice" nil nil 'macro))
191 (autoload 'Info-directory "info" nil t)
192 (autoload 'Info-menu "info" nil t)
193 (autoload 'annotations-at "annotations")
194 (autoload 'apropos "apropos" nil t)
195 (autoload 'apropos-command "apropos" nil t)
196 (autoload 'bbdb-complete-name "bbdb-com" nil t)
197 (autoload 'browse-url "browse-url" nil t)
198 (autoload 'customize-apropos "cus-edit" nil t)
199 (autoload 'customize-save-variable "cus-edit" nil t)
200 (autoload 'customize-variable "cus-edit" nil t)
201 (autoload 'delete-annotation "annotations")
202 (autoload 'dolist "cl-macs" nil nil 'macro)
203 (autoload 'enriched-decode "enriched")
204 (autoload 'info "info" nil t)
205 (autoload 'make-annotation "annotations")
206 (autoload 'make-display-table "disp-table")
208 (autoload 'ps-despool "ps-print" nil t)
209 (autoload 'ps-spool-buffer "ps-print" nil t)
210 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
211 (autoload 'read-passwd "passwd")
212 (autoload 'regexp-opt "regexp-opt")
213 (autoload 'reporter-submit-bug-report "reporter")
214 (if (emacs-version>= 21 5)
215 (autoload 'setenv "process" nil t)
216 (autoload 'setenv "env" nil t))
217 (autoload 'smtpmail-send-it "smtpmail")
218 (autoload 'sort-numeric-fields "sort" nil t)
219 (autoload 'sort-subr "sort")
220 (autoload 'trace-function-background "trace" nil t)
221 (autoload 'w3-do-setup "w3")
222 (autoload 'w3-prepare-buffer "w3-display")
223 (autoload 'w3-region "w3-display" nil t)
224 (defalias 'frame-char-height 'frame-height)
225 (defalias 'frame-char-width 'frame-width)
226 (defalias 'frame-parameter 'frame-property)
227 (defalias 'make-overlay 'ignore)
228 (defalias 'overlay-end 'ignore)
229 (defalias 'overlay-get 'ignore)
230 (defalias 'overlay-put 'ignore)
231 (defalias 'overlay-start 'ignore)
232 (defalias 'overlays-in 'ignore)
233 (defalias 'replace-dehighlight 'ignore)
234 (defalias 'replace-highlight 'ignore)
235 (defalias 'run-with-idle-timer 'ignore)
236 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
238 (defun dgnushack-compile-verbosely ()
239 "Call dgnushack-compile with warnings ENABLED. If you are compiling
240 patches to gnus, you should consider modifying make.bat to call
241 dgnushack-compile-verbosely. All other users should continue to use
243 (dgnushack-compile t))
245 (defun dgnushack-compile (&optional warn)
246 ;;(setq byte-compile-dynamic t)
247 (when (and (not (featurep 'xemacs))
248 (< emacs-major-version 21))
249 (setq max-specpdl-size 1200))
251 (setq byte-compile-warnings
252 '(free-vars unresolved callargs redefine)))
253 (unless (locate-library "cus-edit")
254 (error "You do not seem to have Custom installed.
255 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
256 You also then need to add the following to the lisp/dgnushack.el file:
258 (push \"~/lisp/custom\" load-path)
260 Modify to suit your needs."))
261 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
262 ;;(byte-compile-generate-call-tree t)
264 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
266 (when (featurep 'xemacs)
267 (setq gnus-xmas-glyph-directory "dummy"))
268 (dolist (file '("dgnushack.el" "lpath.el"))
269 (setq files (delete file files)))
270 (when (featurep 'base64)
271 (setq files (delete "base64.el" files)))
275 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
276 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
277 (setq files (delete file files)))))
281 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
282 (setq files (delete "gnus-mh.el" files))))
286 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
287 (setq files (delete "nnrss.el" files))))
289 (if (featurep 'xemacs)
291 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el")))
292 (setq files (delete file files)))
295 (setq file (expand-file-name file srcdir))
296 (when (and (file-exists-p
297 (setq elc (concat (file-name-nondirectory file) "c")))
298 (file-newer-than-file-p file elc))
301 (while (setq file (pop files))
302 (setq file (expand-file-name file srcdir))
303 (when (or (not (file-exists-p
304 (setq elc (concat (file-name-nondirectory file) "c"))))
305 (file-newer-than-file-p file elc))
307 (byte-compile-file file))))))
309 (defun dgnushack-recompile ()
311 (byte-recompile-directory "." 0))
313 (defvar dgnushack-gnus-load-file
314 (if (featurep 'xemacs)
315 (expand-file-name "auto-autoloads.el")
316 (expand-file-name "gnus-load.el")))
318 (defvar dgnushack-cus-load-file
319 (if (featurep 'xemacs)
320 (expand-file-name "custom-load.el")
321 (expand-file-name "cus-load.el")))
323 (defun dgnushack-make-cus-load ()
325 (let ((cusload-base-file dgnushack-cus-load-file))
326 (if (fboundp 'custom-make-dependencies)
327 (custom-make-dependencies)
328 (Custom-make-dependencies))
329 (when (featurep 'xemacs)
330 (message "Compiling %s..." dgnushack-cus-load-file)
331 (byte-compile-file dgnushack-cus-load-file))))
333 (defun dgnushack-make-auto-load ()
335 (unless (make-autoload '(define-derived-mode child parent name
338 (defadvice make-autoload (around handle-define-derived-mode activate)
339 "Handle `define-derived-mode'."
340 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
341 (setq ad-return-value
343 (list 'quote (nth 1 (ad-get-arg 0)))
345 (nth 4 (ad-get-arg 0))
348 (put 'define-derived-mode 'doc-string-elt 3))
349 (let ((generated-autoload-file dgnushack-gnus-load-file)
350 (make-backup-files nil)
351 (autoload-package-name "gnus"))
352 (if (featurep 'xemacs)
353 (if (file-exists-p generated-autoload-file)
354 (delete-file generated-autoload-file))
355 (with-temp-file generated-autoload-file
357 (batch-update-autoloads)))
359 (defun dgnushack-make-load ()
360 (unless (featurep 'xemacs)
361 (message "Generating %s..." dgnushack-gnus-load-file)
362 (with-temp-file dgnushack-gnus-load-file
363 (insert-file-contents dgnushack-cus-load-file)
364 (delete-file dgnushack-cus-load-file)
365 (goto-char (point-min))
366 (search-forward ";;; Code:")
368 (delete-region (point-min) (point))
370 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
374 (goto-char (point-max))
375 (if (search-backward "custom-versions-load-alist" nil t)
378 (while (eq (char-after) ?\;)
381 (delete-region (point) (point-max))
383 ;; smiley-* are duplicated. Remove them all.
384 (let ((point (point)))
385 (insert-file-contents dgnushack-gnus-load-file)
387 (while (search-forward "smiley-" nil t)
389 (if (looking-at "(autoload ")
390 (delete-region (point) (progn (forward-sexp) (point)))
393 (goto-char (point-max))
394 (when (search-backward "\n(provide " nil t)
396 (delete-region (point) (point-max)))
399 \(provide 'gnus-load)
402 ;;; version-control: never
403 ;;; no-byte-compile: t
404 ;;; no-update-autoloads: t
406 ;;; gnus-load.el ends here
409 (message "Compiling %s..." dgnushack-gnus-load-file)
410 (byte-compile-file dgnushack-gnus-load-file)
411 (when (featurep 'xemacs)
412 (message "Creating dummy gnus-load.el...")
413 (with-temp-file (expand-file-name "gnus-load.el")
416 \(provide 'gnus-load)
419 ;;; version-control: never
420 ;;; no-byte-compile: t
421 ;;; no-update-autoloads: t
423 ;;; gnus-load.el ends here"))))
426 ;;; dgnushack.el ends here