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 ;; If we are building w3 in a different directory than the source
52 ;; directory, we must read *.el from source directory and write *.elc
53 ;; into the building directory. For that, we define this function
54 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
55 (defun byte-compile-dest-file (filename)
56 "Convert an Emacs Lisp source file name to a compiled file name.
57 In addition, remove directory name part from FILENAME."
58 (setq filename (byte-compiler-base-file-name filename))
59 (setq filename (file-name-sans-versions filename))
60 (setq filename (file-name-nondirectory filename))
61 (if (memq system-type '(win32 w32 mswindows windows-nt))
62 (setq filename (downcase filename)))
63 (cond ((eq system-type 'vax-vms)
64 (concat (substring filename 0 (string-match ";" filename)) "c"))
65 ((string-match emacs-lisp-file-regexp filename)
66 (concat (substring filename 0 (match-beginning 0)) ".elc"))
67 (t (concat filename ".elc"))))
70 ;; To avoid having defsubsts and inlines happen.
71 ;(if (featurep 'xemacs)
72 ; (require 'byte-optimize)
73 ; (require 'byte-opt))
74 ;(defun byte-optimize-inline-handler (form)
75 ; "byte-optimize-handler for the `inline' special-form."
76 ; (cons 'progn (cdr form)))
77 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
79 (when (and (not (featurep 'xemacs))
80 (= emacs-major-version 21)
81 (= emacs-minor-version 3)
83 (let ((byte-compile-error-on-warn t))
84 (byte-optimize-form (quote (pop x)) t)
86 (error (string-match "called for effect"
87 (error-message-string code)))))
88 (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
91 "Silence the warning \"...called for effect\" for the `pop' form.
92 It is effective only when the `pop' macro is defined by cl.el rather
95 (if (and (eq (car-safe form) 'car)
97 (setq tmp (get 'car 'side-effect-free))
98 (not byte-compile-delete-errors)
99 (not (eq tmp 'error-free))
100 (eq (car-safe (cadr form)) 'prog1)
101 (let ((var (cadr (cadr form)))
102 (last (nth 2 (cadr form))))
104 (null (nthcdr 3 (cadr form)))
105 (eq (car-safe last) 'setq)
107 (eq (car-safe (nth 2 last)) 'cdr)
108 (eq (cadr (nth 2 last)) var))))
110 (put 'car 'side-effect-free 'error-free)
113 (put 'car 'side-effect-free tmp)))
116 (push srcdir load-path)
117 (load (expand-file-name "lpath.el" srcdir) nil t)
119 (defalias 'device-sound-enabled-p 'ignore)
120 (defalias 'play-sound-file 'ignore)
121 (defalias 'nndb-request-article 'ignore)
122 (defalias 'efs-re-read-dir 'ignore)
123 (defalias 'ange-ftp-re-read-dir 'ignore)
124 (defalias 'define-mail-user-agent 'ignore)
127 (unless (featurep 'xemacs)
128 (defalias 'get-popup-menu-response 'ignore)
129 (defalias 'event-object 'ignore)
130 (defalias 'x-defined-colors 'ignore)
131 (defalias 'read-color 'ignore)))
134 (when (featurep 'xemacs)
135 (unless (fboundp 'defadvice)
136 (autoload 'defadvice "advice" nil nil 'macro))
137 (autoload 'Info-directory "info" nil t)
138 (autoload 'Info-menu "info" nil t)
139 (autoload 'annotations-at "annotations")
140 (autoload 'apropos "apropos" nil t)
141 (autoload 'apropos-command "apropos" nil t)
142 (autoload 'bbdb-complete-name "bbdb-com" nil t)
143 (autoload 'browse-url "browse-url" nil t)
144 (autoload 'customize-apropos "cus-edit" nil t)
145 (autoload 'customize-save-variable "cus-edit" nil t)
146 (autoload 'customize-variable "cus-edit" nil t)
147 (autoload 'delete-annotation "annotations")
148 (autoload 'dolist "cl-macs" nil nil 'macro)
149 (autoload 'enriched-decode "enriched")
150 (autoload 'executable-find "executable")
151 (autoload 'font-lock-fontify-buffer "font-lock" nil t)
152 (autoload 'info "info" nil t)
153 (autoload 'make-annotation "annotations")
154 (autoload 'make-display-table "disp-table")
156 (autoload 'ps-despool "ps-print" nil t)
157 (autoload 'ps-spool-buffer "ps-print" nil t)
158 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
159 (autoload 'read-passwd "passwd")
160 (autoload 'regexp-opt "regexp-opt")
161 (autoload 'reporter-submit-bug-report "reporter")
162 (if (emacs-version>= 21 5)
163 (autoload 'setenv "process" nil t)
164 (autoload 'setenv "env" nil t))
165 (autoload 'smtpmail-send-it "smtpmail")
166 (autoload 'sort-numeric-fields "sort" nil t)
167 (autoload 'sort-subr "sort")
168 (autoload 'trace-function-background "trace" nil t)
169 (autoload 'w3-do-setup "w3")
170 (autoload 'w3-prepare-buffer "w3-display")
171 (autoload 'w3-region "w3-display" nil t)
172 (defalias 'frame-char-height 'frame-height)
173 (defalias 'frame-char-width 'frame-width)
174 (defalias 'frame-parameter 'frame-property)
175 (defalias 'make-overlay 'ignore)
176 (defalias 'overlay-end 'ignore)
177 (defalias 'overlay-get 'ignore)
178 (defalias 'overlay-put 'ignore)
179 (defalias 'overlay-start 'ignore)
180 (defalias 'overlays-in 'ignore)
181 (defalias 'replace-dehighlight 'ignore)
182 (defalias 'replace-highlight 'ignore)
183 (defalias 'run-with-idle-timer 'ignore)
184 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
186 (defun dgnushack-compile-verbosely ()
187 "Call dgnushack-compile with warnings ENABLED. If you are compiling
188 patches to gnus, you should consider modifying make.bat to call
189 dgnushack-compile-verbosely. All other users should continue to use
191 (dgnushack-compile t))
193 (defun dgnushack-compile (&optional warn)
194 ;;(setq byte-compile-dynamic t)
196 (setq byte-compile-warnings
197 '(free-vars unresolved callargs redefine)))
198 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
199 ;;(byte-compile-generate-call-tree t)
201 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
203 (when (featurep 'xemacs)
204 (setq gnus-xmas-glyph-directory "dummy"))
205 (dolist (file '("dgnushack.el" "lpath.el"))
206 (setq files (delete file files)))
207 (when (featurep 'base64)
208 (setq files (delete "base64.el" files)))
212 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
213 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
214 (setq files (delete file files)))))
218 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
219 (setq files (delete "gnus-mh.el" files))))
223 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
224 (setq files (delete "nnrss.el" files))))
226 (if (featurep 'xemacs)
228 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el"
230 (setq files (delete file files)))
233 (setq file (expand-file-name file srcdir))
234 (when (and (file-exists-p
235 (setq elc (concat (file-name-nondirectory file) "c")))
236 (file-newer-than-file-p file elc))
239 (while (setq file (pop files))
240 (setq file (expand-file-name file srcdir))
241 (when (or (not (file-exists-p
242 (setq elc (concat (file-name-nondirectory file) "c"))))
243 (file-newer-than-file-p file elc))
245 (byte-compile-file file))))))
247 (defun dgnushack-recompile ()
249 (byte-recompile-directory "." 0))
251 (defvar dgnushack-gnus-load-file
252 (if (featurep 'xemacs)
253 (expand-file-name "auto-autoloads.el")
254 (expand-file-name "gnus-load.el")))
256 (defvar dgnushack-cus-load-file
257 (if (featurep 'xemacs)
258 (expand-file-name "custom-load.el")
259 (expand-file-name "cus-load.el")))
261 (defun dgnushack-make-cus-load ()
263 (let ((cusload-base-file dgnushack-cus-load-file))
264 (if (fboundp 'custom-make-dependencies)
265 (custom-make-dependencies)
266 (Custom-make-dependencies))
267 (when (featurep 'xemacs)
268 (message "Compiling %s..." dgnushack-cus-load-file)
269 (byte-compile-file dgnushack-cus-load-file))))
271 (defun dgnushack-make-auto-load ()
273 (unless (make-autoload '(define-derived-mode child parent name
276 (defadvice make-autoload (around handle-define-derived-mode activate)
277 "Handle `define-derived-mode'."
278 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
279 (setq ad-return-value
281 (list 'quote (nth 1 (ad-get-arg 0)))
283 (nth 4 (ad-get-arg 0))
286 (put 'define-derived-mode 'doc-string-elt 3))
287 (let ((generated-autoload-file dgnushack-gnus-load-file)
288 (make-backup-files nil)
289 (autoload-package-name "gnus"))
290 (if (featurep 'xemacs)
291 (if (file-exists-p generated-autoload-file)
292 (delete-file generated-autoload-file))
293 (with-temp-file generated-autoload-file
295 (batch-update-autoloads)))
297 (defun dgnushack-make-load ()
298 (unless (featurep 'xemacs)
299 (message "Generating %s..." dgnushack-gnus-load-file)
300 (with-temp-file dgnushack-gnus-load-file
301 (insert-file-contents dgnushack-cus-load-file)
302 (delete-file dgnushack-cus-load-file)
303 (goto-char (point-min))
304 (search-forward ";;; Code:")
306 (delete-region (point-min) (point))
308 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
312 (goto-char (point-max))
313 (if (search-backward "custom-versions-load-alist" nil t)
316 (while (eq (char-after) ?\;)
319 (delete-region (point) (point-max))
321 ;; smiley-* are duplicated. Remove them all.
322 (let ((point (point)))
323 (insert-file-contents dgnushack-gnus-load-file)
325 (while (search-forward "smiley-" nil t)
327 (if (looking-at "(autoload ")
328 (delete-region (point) (progn (forward-sexp) (point)))
331 (goto-char (point-max))
332 (when (search-backward "\n(provide " nil t)
334 (delete-region (point) (point-max)))
337 \(provide 'gnus-load)
340 ;;; version-control: never
341 ;;; no-byte-compile: t
342 ;;; no-update-autoloads: t
344 ;;; gnus-load.el ends here
347 (message "Compiling %s..." dgnushack-gnus-load-file)
348 (byte-compile-file dgnushack-gnus-load-file)
349 (when (featurep 'xemacs)
350 (message "Creating dummy gnus-load.el...")
351 (with-temp-file (expand-file-name "gnus-load.el")
354 \(provide 'gnus-load)
357 ;;; version-control: never
358 ;;; no-byte-compile: t
359 ;;; no-update-autoloads: t
361 ;;; gnus-load.el ends here"))))
364 ;;; dgnushack.el ends here