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,
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; Keywords: news, path
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (defalias 'facep 'ignore)
35 (defvar srcdir (or (getenv "srcdir") "."))
36 (defvar loaddir (and load-file-name (file-name-directory load-file-name)))
38 (defun my-getenv (str)
39 (let ((val (getenv str)))
40 (if (equal val "no") nil val)))
42 (if (my-getenv "lispdir")
43 (push (my-getenv "lispdir") load-path))
45 (push (or (my-getenv "URLDIR") (expand-file-name "../../url/lisp/" loaddir))
48 (push (or (my-getenv "W3DIR") (expand-file-name "../../w3/lisp/" loaddir))
51 ;(push "/usr/share/emacs/site-lisp" load-path)
53 ;; If we are building w3 in a different directory than the source
54 ;; directory, we must read *.el from source directory and write *.elc
55 ;; into the building directory. For that, we define this function
56 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
57 (defun byte-compile-dest-file (filename)
58 "Convert an Emacs Lisp source file name to a compiled file name.
59 In addition, remove directory name part from FILENAME."
60 (setq filename (byte-compiler-base-file-name filename))
61 (setq filename (file-name-sans-versions filename))
62 (setq filename (file-name-nondirectory filename))
63 (if (memq system-type '(win32 w32 mswindows windows-nt))
64 (setq filename (downcase filename)))
65 (cond ((eq system-type 'vax-vms)
66 (concat (substring filename 0 (string-match ";" filename)) "c"))
67 ((string-match emacs-lisp-file-regexp filename)
68 (concat (substring filename 0 (match-beginning 0)) ".elc"))
69 (t (concat filename ".elc"))))
72 ;; To avoid having defsubsts and inlines happen.
73 ;(if (featurep 'xemacs)
74 ; (require 'byte-optimize)
75 ; (require 'byte-opt))
76 ;(defun byte-optimize-inline-handler (form)
77 ; "byte-optimize-handler for the `inline' special-form."
78 ; (cons 'progn (cdr form)))
79 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
81 (when (and (not (featurep 'xemacs))
82 (= emacs-major-version 21)
83 (>= emacs-minor-version 3)
85 (let ((byte-compile-error-on-warn t))
86 (byte-optimize-form (quote (pop x)) t)
88 (error (string-match "called for effect"
89 (error-message-string code)))))
90 (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
93 "Silence the warning \"...called for effect\" for the `pop' form.
94 It is effective only when the `pop' macro is defined by cl.el rather
97 (if (and (eq (car-safe form) 'car)
99 (setq tmp (get 'car 'side-effect-free))
100 (not byte-compile-delete-errors)
101 (not (eq tmp 'error-free))
102 (eq (car-safe (cadr form)) 'prog1)
103 (let ((var (cadr (cadr form)))
104 (last (nth 2 (cadr form))))
106 (null (nthcdr 3 (cadr form)))
107 (eq (car-safe last) 'setq)
109 (eq (car-safe (nth 2 last)) 'cdr)
110 (eq (cadr (nth 2 last)) var))))
112 (put 'car 'side-effect-free 'error-free)
115 (put 'car 'side-effect-free tmp)))
118 (when (and (not (featurep 'xemacs))
119 (byte-optimize-form '(and (> 0 1) foo) t))
120 (defadvice byte-optimize-form-code-walker
121 (around fix-bug-in-and/or-forms (form for-effect) activate)
122 "Optimize the rest of the and/or forms.
123 It has been fixed in XEmacs before releasing 21.4 and also has been
124 fixed in Emacs after 21.3."
125 (if (and for-effect (memq (car-safe form) '(and or)))
126 (let ((fn (car form))
127 (backwards (reverse (cdr form))))
128 (while (and backwards
129 (null (setcar backwards
130 (byte-optimize-form (car backwards) t))))
131 (setq backwards (cdr backwards)))
132 (if (and (cdr form) (null backwards))
134 " all subforms of %s called for effect; deleted" form))
137 (mapcar 'byte-optimize-form (cdr backwards))))
138 (setq ad-return-value (cons fn (nreverse backwards))))
141 (when (and (featurep 'xemacs)
142 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
143 (modify-syntax-entry ?= " " table)
145 (with-syntax-table table
147 (goto-char (point-min))
150 ;; The original `with-syntax-table' uses `copy-syntax-table' which
151 ;; doesn't seem to copy modified syntax entries in XEmacs 21.5.
152 (defmacro with-syntax-table (syntab &rest body)
153 "Evaluate BODY with the SYNTAB as the current syntax table."
154 `(let ((stab (syntax-table)))
157 ;;(set-syntax-table (copy-syntax-table ,syntab))
158 (set-syntax-table ,syntab)
160 (set-syntax-table stab)))))
162 (push srcdir load-path)
163 (push loaddir load-path)
164 (load (expand-file-name "lpath.el" loaddir) nil t)
166 (defalias 'device-sound-enabled-p 'ignore)
167 (defalias 'play-sound-file 'ignore)
168 (defalias 'nndb-request-article 'ignore)
169 (defalias 'efs-re-read-dir 'ignore)
170 (defalias 'ange-ftp-re-read-dir 'ignore)
171 (defalias 'define-mail-user-agent 'ignore)
174 (unless (featurep 'xemacs)
175 (defalias 'get-popup-menu-response 'ignore)
176 (defalias 'event-object 'ignore)
177 (defalias 'x-defined-colors 'ignore)
178 (defalias 'read-color 'ignore)))
181 (when (featurep 'xemacs)
182 (unless (fboundp 'defadvice)
183 (autoload 'defadvice "advice" nil nil 'macro))
184 (autoload 'Info-directory "info" nil t)
185 (autoload 'Info-menu "info" nil t)
186 (autoload 'annotations-at "annotations")
187 (autoload 'apropos "apropos" nil t)
188 (autoload 'apropos-command "apropos" nil t)
189 (autoload 'bbdb-complete-name "bbdb-com" nil t)
190 (autoload 'browse-url "browse-url" nil t)
191 (autoload 'c-mode "cc-mode" nil t)
192 (autoload 'customize-apropos "cus-edit" nil t)
193 (autoload 'customize-save-variable "cus-edit" nil t)
194 (autoload 'customize-set-variable "cus-edit" nil t)
195 (autoload 'customize-variable "cus-edit" nil t)
196 (autoload 'delete-annotation "annotations")
197 (autoload 'dolist "cl-macs" nil nil 'macro)
198 (autoload 'enriched-decode "enriched")
199 (autoload 'executable-find "executable")
200 (autoload 'font-lock-fontify-buffer "font-lock" nil t)
201 (autoload 'info "info" nil t)
202 (autoload 'mail-extract-address-components "mail-extr")
203 (autoload 'mail-fetch-field "mail-utils")
204 (autoload 'make-annotation "annotations")
205 (autoload 'make-display-table "disp-table")
207 (autoload 'ps-despool "ps-print" nil t)
208 (autoload 'ps-spool-buffer "ps-print" nil t)
209 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
210 (autoload 'read-passwd "passwd")
211 (autoload 'regexp-opt "regexp-opt")
212 (autoload 'reporter-submit-bug-report "reporter")
213 (if (and (emacs-version>= 21 5)
214 (not (featurep 'sxemacs)))
215 (autoload 'setenv "process" nil t)
216 (autoload 'setenv "env" nil t))
217 (autoload 'sgml-mode "psgml" nil t)
218 (autoload 'smtpmail-send-it "smtpmail")
219 (autoload 'sort-numeric-fields "sort" nil t)
220 (autoload 'sort-subr "sort")
221 (autoload 'trace-function-background "trace" nil t)
222 (autoload 'w3-do-setup "w3")
223 (autoload 'w3-prepare-buffer "w3-display")
224 (autoload 'w3-region "w3-display" nil t)
225 (defalias 'frame-char-height 'frame-height)
226 (defalias 'frame-char-width 'frame-width)
227 (defalias 'frame-parameter 'frame-property)
228 (defalias 'make-overlay 'ignore)
229 (defalias 'overlay-end 'ignore)
230 (defalias 'overlay-get 'ignore)
231 (defalias 'overlay-put 'ignore)
232 (defalias 'overlay-start 'ignore)
233 (defalias 'overlays-in 'ignore)
234 (defalias 'replace-dehighlight 'ignore)
235 (defalias 'replace-highlight '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)
248 (setq byte-compile-warnings
249 '(free-vars unresolved callargs redefine)))
250 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
251 ;;(byte-compile-generate-call-tree t)
253 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
255 (when (featurep 'xemacs)
256 (setq gnus-xmas-glyph-directory "dummy"))
257 (dolist (file '("dgnushack.el" "lpath.el"))
258 (setq files (delete file files)))
259 (when (featurep 'base64)
260 (setq files (delete "base64.el" files)))
264 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
265 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
266 (setq files (delete file files)))))
270 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
271 (setq files (delete "gnus-mh.el" files))))
275 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
276 (setq files (delete "nnrss.el" files))))
278 (if (featurep 'xemacs)
280 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el")))
281 (setq files (delete file files)))
284 (setq file (expand-file-name file srcdir))
285 (when (and (file-exists-p
286 (setq elc (concat (file-name-nondirectory file) "c")))
287 (file-newer-than-file-p file elc))
290 (while (setq file (pop files))
291 (setq file (expand-file-name file srcdir))
292 (when (or (not (file-exists-p
293 (setq elc (concat (file-name-nondirectory file) "c"))))
294 (file-newer-than-file-p file elc))
296 (byte-compile-file file))))))
298 (defun dgnushack-recompile ()
300 (byte-recompile-directory "." 0))
302 (defvar dgnushack-gnus-load-file
303 (if (featurep 'xemacs)
304 (expand-file-name "auto-autoloads.el")
305 (expand-file-name "gnus-load.el")))
307 (defvar dgnushack-cus-load-file
308 (if (featurep 'xemacs)
309 (expand-file-name "custom-load.el")
310 (expand-file-name "cus-load.el")))
312 (defun dgnushack-make-cus-load ()
314 (let ((cusload-base-file dgnushack-cus-load-file))
315 (if (fboundp 'custom-make-dependencies)
316 (custom-make-dependencies)
317 (Custom-make-dependencies))
318 (when (featurep 'xemacs)
319 (message "Compiling %s..." dgnushack-cus-load-file)
320 (byte-compile-file dgnushack-cus-load-file))))
322 (defun dgnushack-make-auto-load ()
324 (unless (make-autoload '(define-derived-mode child parent name
327 (defadvice make-autoload (around handle-define-derived-mode activate)
328 "Handle `define-derived-mode'."
329 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
330 (setq ad-return-value
332 (list 'quote (nth 1 (ad-get-arg 0)))
334 (nth 4 (ad-get-arg 0))
337 (put 'define-derived-mode 'doc-string-elt 3))
338 (let ((generated-autoload-file dgnushack-gnus-load-file)
339 (make-backup-files nil)
340 (autoload-package-name "gnus"))
341 (if (featurep 'xemacs)
342 (if (file-exists-p generated-autoload-file)
343 (delete-file generated-autoload-file))
344 (with-temp-file generated-autoload-file
346 (batch-update-autoloads)))
348 (defun dgnushack-make-load ()
349 (unless (featurep 'xemacs)
350 (message "Generating %s..." dgnushack-gnus-load-file)
351 (with-temp-file dgnushack-gnus-load-file
352 (insert-file-contents dgnushack-cus-load-file)
353 (delete-file dgnushack-cus-load-file)
354 (goto-char (point-min))
355 (search-forward ";;; Code:")
357 (delete-region (point-min) (point))
359 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
363 (goto-char (point-max))
364 (if (search-backward "custom-versions-load-alist" nil t)
367 (while (eq (char-after) ?\;)
370 (delete-region (point) (point-max))
372 ;; smiley-* are duplicated. Remove them all.
373 (let ((point (point)))
374 (insert-file-contents dgnushack-gnus-load-file)
376 (while (search-forward "smiley-" nil t)
378 (if (looking-at "(autoload ")
379 (delete-region (point) (progn (forward-sexp) (point)))
382 (goto-char (point-max))
383 (when (search-backward "\n(provide " nil t)
385 (delete-region (point) (point-max)))
388 \(provide 'gnus-load)
391 ;;; version-control: never
392 ;;; no-byte-compile: t
393 ;;; no-update-autoloads: t
395 ;;; gnus-load.el ends here
398 (message "Compiling %s..." dgnushack-gnus-load-file)
399 (byte-compile-file dgnushack-gnus-load-file)
400 (when (featurep 'xemacs)
401 (message "Creating dummy gnus-load.el...")
402 (with-temp-file (expand-file-name "gnus-load.el")
405 \(provide 'gnus-load)
408 ;;; version-control: never
409 ;;; no-byte-compile: t
410 ;;; no-update-autoloads: t
412 ;;; gnus-load.el ends here"))))
414 ;;; dgnushack.el ends here
416 ;;; arch-tag: 579f585a-24eb-4e1c-8d34-4808e11b68f2