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 'info "info" nil t)
152 (autoload 'make-annotation "annotations")
153 (autoload 'make-display-table "disp-table")
155 (autoload 'ps-despool "ps-print" nil t)
156 (autoload 'ps-spool-buffer "ps-print" nil t)
157 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
158 (autoload 'read-passwd "passwd")
159 (autoload 'regexp-opt "regexp-opt")
160 (autoload 'reporter-submit-bug-report "reporter")
161 (if (emacs-version>= 21 5)
162 (autoload 'setenv "process" nil t)
163 (autoload 'setenv "env" nil t))
164 (autoload 'smtpmail-send-it "smtpmail")
165 (autoload 'sort-numeric-fields "sort" nil t)
166 (autoload 'sort-subr "sort")
167 (autoload 'trace-function-background "trace" nil t)
168 (autoload 'w3-do-setup "w3")
169 (autoload 'w3-prepare-buffer "w3-display")
170 (autoload 'w3-region "w3-display" nil t)
171 (defalias 'frame-char-height 'frame-height)
172 (defalias 'frame-char-width 'frame-width)
173 (defalias 'frame-parameter 'frame-property)
174 (defalias 'make-overlay 'ignore)
175 (defalias 'overlay-end 'ignore)
176 (defalias 'overlay-get 'ignore)
177 (defalias 'overlay-put 'ignore)
178 (defalias 'overlay-start 'ignore)
179 (defalias 'overlays-in 'ignore)
180 (defalias 'replace-dehighlight 'ignore)
181 (defalias 'replace-highlight 'ignore)
182 (defalias 'run-with-idle-timer 'ignore)
183 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
185 (defun dgnushack-compile-verbosely ()
186 "Call dgnushack-compile with warnings ENABLED. If you are compiling
187 patches to gnus, you should consider modifying make.bat to call
188 dgnushack-compile-verbosely. All other users should continue to use
190 (dgnushack-compile t))
192 (defun dgnushack-compile (&optional warn)
193 ;;(setq byte-compile-dynamic t)
195 (setq byte-compile-warnings
196 '(free-vars unresolved callargs redefine)))
197 (unless (locate-library "cus-edit")
198 (error "You do not seem to have Custom installed.
199 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
200 You also then need to add the following to the lisp/dgnushack.el file:
202 (push \"~/lisp/custom\" load-path)
204 Modify to suit your needs."))
205 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
206 ;;(byte-compile-generate-call-tree t)
208 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
210 (when (featurep 'xemacs)
211 (setq gnus-xmas-glyph-directory "dummy"))
212 (dolist (file '("dgnushack.el" "lpath.el"))
213 (setq files (delete file files)))
214 (when (featurep 'base64)
215 (setq files (delete "base64.el" files)))
219 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
220 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
221 (setq files (delete file files)))))
225 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
226 (setq files (delete "gnus-mh.el" files))))
230 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
231 (setq files (delete "nnrss.el" files))))
233 (if (featurep 'xemacs)
235 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.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
258 (if (featurep 'xemacs)
259 (expand-file-name "auto-autoloads.el")
260 (expand-file-name "gnus-load.el")))
262 (defvar dgnushack-cus-load-file
263 (if (featurep 'xemacs)
264 (expand-file-name "custom-load.el")
265 (expand-file-name "cus-load.el")))
267 (defun dgnushack-make-cus-load ()
269 (let ((cusload-base-file dgnushack-cus-load-file))
270 (if (fboundp 'custom-make-dependencies)
271 (custom-make-dependencies)
272 (Custom-make-dependencies))
273 (when (featurep 'xemacs)
274 (message "Compiling %s..." dgnushack-cus-load-file)
275 (byte-compile-file dgnushack-cus-load-file))))
277 (defun dgnushack-make-auto-load ()
279 (unless (make-autoload '(define-derived-mode child parent name
282 (defadvice make-autoload (around handle-define-derived-mode activate)
283 "Handle `define-derived-mode'."
284 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
285 (setq ad-return-value
287 (list 'quote (nth 1 (ad-get-arg 0)))
289 (nth 4 (ad-get-arg 0))
292 (put 'define-derived-mode 'doc-string-elt 3))
293 (let ((generated-autoload-file dgnushack-gnus-load-file)
294 (make-backup-files nil)
295 (autoload-package-name "gnus"))
296 (if (featurep 'xemacs)
297 (if (file-exists-p generated-autoload-file)
298 (delete-file generated-autoload-file))
299 (with-temp-file generated-autoload-file
301 (batch-update-autoloads)))
303 (defun dgnushack-make-load ()
304 (unless (featurep 'xemacs)
305 (message "Generating %s..." dgnushack-gnus-load-file)
306 (with-temp-file dgnushack-gnus-load-file
307 (insert-file-contents dgnushack-cus-load-file)
308 (delete-file dgnushack-cus-load-file)
309 (goto-char (point-min))
310 (search-forward ";;; Code:")
312 (delete-region (point-min) (point))
314 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
318 (goto-char (point-max))
319 (if (search-backward "custom-versions-load-alist" nil t)
322 (while (eq (char-after) ?\;)
325 (delete-region (point) (point-max))
327 ;; smiley-* are duplicated. Remove them all.
328 (let ((point (point)))
329 (insert-file-contents dgnushack-gnus-load-file)
331 (while (search-forward "smiley-" nil t)
333 (if (looking-at "(autoload ")
334 (delete-region (point) (progn (forward-sexp) (point)))
337 (goto-char (point-max))
338 (when (search-backward "\n(provide " nil t)
340 (delete-region (point) (point-max)))
343 \(provide 'gnus-load)
346 ;;; version-control: never
347 ;;; no-byte-compile: t
348 ;;; no-update-autoloads: t
350 ;;; gnus-load.el ends here
353 (message "Compiling %s..." dgnushack-gnus-load-file)
354 (byte-compile-file dgnushack-gnus-load-file)
355 (when (featurep 'xemacs)
356 (message "Creating dummy gnus-load.el...")
357 (with-temp-file (expand-file-name "gnus-load.el")
360 \(provide 'gnus-load)
363 ;;; version-control: never
364 ;;; no-byte-compile: t
365 ;;; no-update-autoloads: t
367 ;;; gnus-load.el ends here"))))
370 ;;; dgnushack.el ends here