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") "."))
35 (defvar loaddir (and load-file-name (file-name-directory load-file-name)))
37 (defun my-getenv (str)
38 (let ((val (getenv str)))
39 (if (equal val "no") nil val)))
41 (if (my-getenv "lispdir")
42 (push (my-getenv "lispdir") load-path))
44 (push (or (my-getenv "URLDIR") (expand-file-name "../../url/lisp/" loaddir))
47 (push (or (my-getenv "W3DIR") (expand-file-name "../../w3/lisp/" loaddir))
50 ;(push "/usr/share/emacs/site-lisp" load-path)
52 ;; If we are building w3 in a different directory than the source
53 ;; directory, we must read *.el from source directory and write *.elc
54 ;; into the building directory. For that, we define this function
55 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
56 (defun byte-compile-dest-file (filename)
57 "Convert an Emacs Lisp source file name to a compiled file name.
58 In addition, remove directory name part from FILENAME."
59 (setq filename (byte-compiler-base-file-name filename))
60 (setq filename (file-name-sans-versions filename))
61 (setq filename (file-name-nondirectory filename))
62 (if (memq system-type '(win32 w32 mswindows windows-nt))
63 (setq filename (downcase filename)))
64 (cond ((eq system-type 'vax-vms)
65 (concat (substring filename 0 (string-match ";" filename)) "c"))
66 ((string-match emacs-lisp-file-regexp filename)
67 (concat (substring filename 0 (match-beginning 0)) ".elc"))
68 (t (concat filename ".elc"))))
71 ;; To avoid having defsubsts and inlines happen.
72 ;(if (featurep 'xemacs)
73 ; (require 'byte-optimize)
74 ; (require 'byte-opt))
75 ;(defun byte-optimize-inline-handler (form)
76 ; "byte-optimize-handler for the `inline' special-form."
77 ; (cons 'progn (cdr form)))
78 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
80 (when (and (not (featurep 'xemacs))
81 (= emacs-major-version 21)
82 (= emacs-minor-version 3)
84 (let ((byte-compile-error-on-warn t))
85 (byte-optimize-form (quote (pop x)) t)
87 (error (string-match "called for effect"
88 (error-message-string code)))))
89 (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
92 "Silence the warning \"...called for effect\" for the `pop' form.
93 It is effective only when the `pop' macro is defined by cl.el rather
96 (if (and (eq (car-safe form) 'car)
98 (setq tmp (get 'car 'side-effect-free))
99 (not byte-compile-delete-errors)
100 (not (eq tmp 'error-free))
101 (eq (car-safe (cadr form)) 'prog1)
102 (let ((var (cadr (cadr form)))
103 (last (nth 2 (cadr form))))
105 (null (nthcdr 3 (cadr form)))
106 (eq (car-safe last) 'setq)
108 (eq (car-safe (nth 2 last)) 'cdr)
109 (eq (cadr (nth 2 last)) var))))
111 (put 'car 'side-effect-free 'error-free)
114 (put 'car 'side-effect-free tmp)))
117 (when (and (not (featurep 'xemacs))
118 (byte-optimize-form '(and (> 0 1) foo) t))
119 (defadvice byte-optimize-form-code-walker
120 (around fix-bug-in-and/or-forms (form for-effect) activate)
121 "Optimize the rest of the and/or forms.
122 It has been fixed in XEmacs before releasing 21.4 and also has been
123 fixed in Emacs after 21.3."
124 (if (and for-effect (memq (car-safe form) '(and or)))
125 (let ((fn (car form))
126 (backwards (reverse (cdr form))))
127 (while (and backwards
128 (null (setcar backwards
129 (byte-optimize-form (car backwards) t))))
130 (setq backwards (cdr backwards)))
131 (if (and (cdr form) (null backwards))
133 " all subforms of %s called for effect; deleted" form))
136 (mapcar 'byte-optimize-form (cdr backwards))))
137 (setq ad-return-value (cons fn (nreverse backwards))))
140 (when (and (featurep 'xemacs)
141 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
142 (modify-syntax-entry ?= " " table)
144 (with-syntax-table table
146 (goto-char (point-min))
149 ;; The original `with-syntax-table' uses `copy-syntax-table' which
150 ;; doesn't seem to copy modified syntax entries in XEmacs 21.5.
151 (defmacro with-syntax-table (syntab &rest body)
152 "Evaluate BODY with the SYNTAB as the current syntax table."
153 `(let ((stab (syntax-table)))
156 ;;(set-syntax-table (copy-syntax-table ,syntab))
157 (set-syntax-table ,syntab)
159 (set-syntax-table stab)))))
161 (push srcdir load-path)
162 (push loaddir load-path)
163 (load (expand-file-name "lpath.el" loaddir) nil t)
165 (defalias 'device-sound-enabled-p 'ignore)
166 (defalias 'play-sound-file 'ignore)
167 (defalias 'nndb-request-article 'ignore)
168 (defalias 'efs-re-read-dir 'ignore)
169 (defalias 'ange-ftp-re-read-dir 'ignore)
170 (defalias 'define-mail-user-agent 'ignore)
173 (unless (featurep 'xemacs)
174 (defalias 'get-popup-menu-response 'ignore)
175 (defalias 'event-object 'ignore)
176 (defalias 'x-defined-colors 'ignore)
177 (defalias 'read-color 'ignore)))
180 (when (featurep 'xemacs)
181 (unless (fboundp 'defadvice)
182 (autoload 'defadvice "advice" nil nil 'macro))
183 (autoload 'Info-directory "info" nil t)
184 (autoload 'Info-menu "info" nil t)
185 (autoload 'annotations-at "annotations")
186 (autoload 'apropos "apropos" nil t)
187 (autoload 'apropos-command "apropos" nil t)
188 (autoload 'bbdb-complete-name "bbdb-com" nil t)
189 (autoload 'browse-url "browse-url" nil t)
190 (autoload 'c-mode "cc-mode" nil t)
191 (autoload 'customize-apropos "cus-edit" nil t)
192 (autoload 'customize-save-variable "cus-edit" nil t)
193 (autoload 'customize-set-variable "cus-edit" nil t)
194 (autoload 'customize-variable "cus-edit" nil t)
195 (autoload 'delete-annotation "annotations")
196 (autoload 'dolist "cl-macs" nil nil 'macro)
197 (autoload 'enriched-decode "enriched")
198 (autoload 'executable-find "executable")
199 (autoload 'font-lock-fontify-buffer "font-lock" nil t)
200 (autoload 'info "info" nil t)
201 (autoload 'mail-fetch-field "mail-utils")
202 (autoload 'make-annotation "annotations")
203 (autoload 'make-display-table "disp-table")
205 (autoload 'ps-despool "ps-print" nil t)
206 (autoload 'ps-spool-buffer "ps-print" nil t)
207 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
208 (autoload 'read-passwd "passwd")
209 (autoload 'regexp-opt "regexp-opt")
210 (autoload 'reporter-submit-bug-report "reporter")
211 (if (and (emacs-version>= 21 5)
212 (not (featurep 'sxemacs)))
213 (autoload 'setenv "process" nil t)
214 (autoload 'setenv "env" nil t))
215 (autoload 'sgml-mode "psgml" nil t)
216 (autoload 'smtpmail-send-it "smtpmail")
217 (autoload 'sort-numeric-fields "sort" nil t)
218 (autoload 'sort-subr "sort")
219 (autoload 'trace-function-background "trace" nil t)
220 (autoload 'w3-do-setup "w3")
221 (autoload 'w3-prepare-buffer "w3-display")
222 (autoload 'w3-region "w3-display" nil t)
223 (defalias 'frame-char-height 'frame-height)
224 (defalias 'frame-char-width 'frame-width)
225 (defalias 'frame-parameter 'frame-property)
226 (defalias 'make-overlay 'ignore)
227 (defalias 'overlay-end 'ignore)
228 (defalias 'overlay-get 'ignore)
229 (defalias 'overlay-put 'ignore)
230 (defalias 'overlay-start 'ignore)
231 (defalias 'overlays-in 'ignore)
232 (defalias 'replace-dehighlight 'ignore)
233 (defalias 'replace-highlight 'ignore)
234 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
236 (defun dgnushack-compile-verbosely ()
237 "Call dgnushack-compile with warnings ENABLED. If you are compiling
238 patches to gnus, you should consider modifying make.bat to call
239 dgnushack-compile-verbosely. All other users should continue to use
241 (dgnushack-compile t))
243 (defun dgnushack-compile (&optional warn)
244 ;;(setq byte-compile-dynamic t)
246 (setq byte-compile-warnings
247 '(free-vars unresolved callargs redefine)))
248 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
249 ;;(byte-compile-generate-call-tree t)
251 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
253 (when (featurep 'xemacs)
254 (setq gnus-xmas-glyph-directory "dummy"))
255 (dolist (file '("dgnushack.el" "lpath.el"))
256 (setq files (delete file files)))
257 (when (featurep 'base64)
258 (setq files (delete "base64.el" files)))
262 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
263 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
264 (setq files (delete file files)))))
268 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
269 (setq files (delete "gnus-mh.el" files))))
273 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
274 (setq files (delete "nnrss.el" files))))
276 (if (featurep 'xemacs)
278 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el")))
279 (setq files (delete file files)))
282 (setq file (expand-file-name file srcdir))
283 (when (and (file-exists-p
284 (setq elc (concat (file-name-nondirectory file) "c")))
285 (file-newer-than-file-p file elc))
288 (while (setq file (pop files))
289 (setq file (expand-file-name file srcdir))
290 (when (or (not (file-exists-p
291 (setq elc (concat (file-name-nondirectory file) "c"))))
292 (file-newer-than-file-p file elc))
294 (byte-compile-file file))))))
296 (defun dgnushack-recompile ()
298 (byte-recompile-directory "." 0))
300 (defvar dgnushack-gnus-load-file
301 (if (featurep 'xemacs)
302 (expand-file-name "auto-autoloads.el")
303 (expand-file-name "gnus-load.el")))
305 (defvar dgnushack-cus-load-file
306 (if (featurep 'xemacs)
307 (expand-file-name "custom-load.el")
308 (expand-file-name "cus-load.el")))
310 (defun dgnushack-make-cus-load ()
312 (let ((cusload-base-file dgnushack-cus-load-file))
313 (if (fboundp 'custom-make-dependencies)
314 (custom-make-dependencies)
315 (Custom-make-dependencies))
316 (when (featurep 'xemacs)
317 (message "Compiling %s..." dgnushack-cus-load-file)
318 (byte-compile-file dgnushack-cus-load-file))))
320 (defun dgnushack-make-auto-load ()
322 (unless (make-autoload '(define-derived-mode child parent name
325 (defadvice make-autoload (around handle-define-derived-mode activate)
326 "Handle `define-derived-mode'."
327 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
328 (setq ad-return-value
330 (list 'quote (nth 1 (ad-get-arg 0)))
332 (nth 4 (ad-get-arg 0))
335 (put 'define-derived-mode 'doc-string-elt 3))
336 (let ((generated-autoload-file dgnushack-gnus-load-file)
337 (make-backup-files nil)
338 (autoload-package-name "gnus"))
339 (if (featurep 'xemacs)
340 (if (file-exists-p generated-autoload-file)
341 (delete-file generated-autoload-file))
342 (with-temp-file generated-autoload-file
344 (batch-update-autoloads)))
346 (defun dgnushack-make-load ()
347 (unless (featurep 'xemacs)
348 (message "Generating %s..." dgnushack-gnus-load-file)
349 (with-temp-file dgnushack-gnus-load-file
350 (insert-file-contents dgnushack-cus-load-file)
351 (delete-file dgnushack-cus-load-file)
352 (goto-char (point-min))
353 (search-forward ";;; Code:")
355 (delete-region (point-min) (point))
357 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
361 (goto-char (point-max))
362 (if (search-backward "custom-versions-load-alist" nil t)
365 (while (eq (char-after) ?\;)
368 (delete-region (point) (point-max))
370 ;; smiley-* are duplicated. Remove them all.
371 (let ((point (point)))
372 (insert-file-contents dgnushack-gnus-load-file)
374 (while (search-forward "smiley-" nil t)
376 (if (looking-at "(autoload ")
377 (delete-region (point) (progn (forward-sexp) (point)))
380 (goto-char (point-max))
381 (when (search-backward "\n(provide " nil t)
383 (delete-region (point) (point-max)))
386 \(provide 'gnus-load)
389 ;;; version-control: never
390 ;;; no-byte-compile: t
391 ;;; no-update-autoloads: t
393 ;;; gnus-load.el ends here
396 (message "Compiling %s..." dgnushack-gnus-load-file)
397 (byte-compile-file dgnushack-gnus-load-file)
398 (when (featurep 'xemacs)
399 (message "Creating dummy gnus-load.el...")
400 (with-temp-file (expand-file-name "gnus-load.el")
403 \(provide 'gnus-load)
406 ;;; version-control: never
407 ;;; no-byte-compile: t
408 ;;; no-update-autoloads: t
410 ;;; gnus-load.el ends here"))))
412 ;;; dgnushack.el ends here
414 ;;; arch-tag: 579f585a-24eb-4e1c-8d34-4808e11b68f2