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 ;; If we are building w3 in a different directory than the source
84 ;; directory, we must read *.el from source directory and write *.elc
85 ;; into the building directory. For that, we define this function
86 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
87 (defun byte-compile-dest-file (filename)
88 "Convert an Emacs Lisp source file name to a compiled file name.
89 In addition, remove directory name part from FILENAME."
90 (setq filename (byte-compiler-base-file-name filename))
91 (setq filename (file-name-sans-versions filename))
92 (setq filename (file-name-nondirectory filename))
93 (if (memq system-type '(win32 w32 mswindows windows-nt))
94 (setq filename (downcase filename)))
95 (cond ((eq system-type 'vax-vms)
96 (concat (substring filename 0 (string-match ";" filename)) "c"))
97 ((string-match emacs-lisp-file-regexp filename)
98 (concat (substring filename 0 (match-beginning 0)) ".elc"))
99 (t (concat filename ".elc"))))
102 ;; To avoid having defsubsts and inlines happen.
103 ;(if (featurep 'xemacs)
104 ; (require 'byte-optimize)
105 ; (require 'byte-opt))
106 ;(defun byte-optimize-inline-handler (form)
107 ; "byte-optimize-handler for the `inline' special-form."
108 ; (cons 'progn (cdr form)))
109 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
111 (push srcdir load-path)
112 (load (expand-file-name "lpath.el" srcdir) nil t)
114 (defalias 'device-sound-enabled-p 'ignore)
115 (defalias 'play-sound-file 'ignore)
116 (defalias 'nndb-request-article 'ignore)
117 (defalias 'efs-re-read-dir 'ignore)
118 (defalias 'ange-ftp-re-read-dir 'ignore)
119 (defalias 'define-mail-user-agent 'ignore)
122 (unless (featurep 'xemacs)
123 (defalias 'get-popup-menu-response 'ignore)
124 (defalias 'event-object 'ignore)
125 (defalias 'x-defined-colors 'ignore)
126 (defalias 'read-color 'ignore)))
129 (when (featurep 'xemacs)
130 ;; XEmacs 21.1 needs some extra hand holding
131 (when (eq emacs-minor-version 1)
132 (autoload 'custom-declare-face "cus-face" nil t)
133 (autoload 'cl-compile-time-init "cl-macs" nil t)
134 (autoload 'defadvice "advice" nil nil 'macro))
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 'info "info" nil t)
151 (autoload 'make-annotation "annotations")
152 (autoload 'make-display-table "disp-table")
154 (autoload 'ps-despool "ps-print" nil t)
155 (autoload 'ps-spool-buffer "ps-print" nil t)
156 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
157 (autoload 'read-passwd "passwd")
158 (autoload 'regexp-opt "regexp-opt")
159 (autoload 'reporter-submit-bug-report "reporter")
160 (if (emacs-version>= 21 5)
161 (autoload 'setenv "process" nil t)
162 (autoload 'setenv "env" nil t))
163 (autoload 'smtpmail-send-it "smtpmail")
164 (autoload 'sort-numeric-fields "sort" nil t)
165 (autoload 'sort-subr "sort")
166 (autoload 'trace-function-background "trace" nil t)
167 (autoload 'w3-do-setup "w3")
168 (autoload 'w3-prepare-buffer "w3-display")
169 (autoload 'w3-region "w3-display" nil t)
170 (defalias 'frame-char-height 'frame-height)
171 (defalias 'frame-char-width 'frame-width)
172 (defalias 'frame-parameter 'frame-property)
173 (defalias 'make-overlay 'ignore)
174 (defalias 'overlay-end 'ignore)
175 (defalias 'overlay-get 'ignore)
176 (defalias 'overlay-put 'ignore)
177 (defalias 'overlay-start 'ignore)
178 (defalias 'overlays-in 'ignore)
179 (defalias 'replace-dehighlight 'ignore)
180 (defalias 'replace-highlight 'ignore)
181 (defalias 'run-with-idle-timer 'ignore)
182 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
184 (defun dgnushack-compile-verbosely ()
185 "Call dgnushack-compile with warnings ENABLED. If you are compiling
186 patches to gnus, you should consider modifying make.bat to call
187 dgnushack-compile-verbosely. All other users should continue to use
189 (dgnushack-compile t))
191 (defun dgnushack-compile (&optional warn)
192 ;;(setq byte-compile-dynamic t)
194 (setq byte-compile-warnings
195 '(free-vars unresolved callargs redefine)))
196 (unless (locate-library "cus-edit")
197 (error "You do not seem to have Custom installed.
198 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
199 You also then need to add the following to the lisp/dgnushack.el file:
201 (push \"~/lisp/custom\" load-path)
203 Modify to suit your needs."))
204 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
205 ;;(byte-compile-generate-call-tree t)
207 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
209 (when (featurep 'xemacs)
210 (setq gnus-xmas-glyph-directory "dummy"))
211 (dolist (file '("dgnushack.el" "lpath.el"))
212 (setq files (delete file files)))
213 (when (featurep 'base64)
214 (setq files (delete "base64.el" files)))
218 (message "No w3: %s %s" (cadr code) (or (locate-library "w3-parse") ""))
219 (dolist (file '("nnultimate.el" "webmail.el" "nnwfm.el"))
220 (setq files (delete file files)))))
224 (message "No mh-e: %s %s" (cadr code) (or (locate-library "mh-e") ""))
225 (setq files (delete "gnus-mh.el" files))))
229 (message "No xml: %s %s" (cadr code) (or (locate-library "xml") ""))
230 (setq files (delete "nnrss.el" files))))
232 (if (featurep 'xemacs)
234 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el")))
235 (setq files (delete file files)))
238 (setq file (expand-file-name file srcdir))
239 (when (and (file-exists-p
240 (setq elc (concat (file-name-nondirectory file) "c")))
241 (file-newer-than-file-p file elc))
244 (while (setq file (pop files))
245 (setq file (expand-file-name file srcdir))
246 (when (or (not (file-exists-p
247 (setq elc (concat (file-name-nondirectory file) "c"))))
248 (file-newer-than-file-p file elc))
250 (byte-compile-file file))))))
252 (defun dgnushack-recompile ()
254 (byte-recompile-directory "." 0))
256 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el"))
257 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el"))
259 (defun dgnushack-make-cus-load ()
261 (let ((cusload-base-file dgnushack-cus-load-file))
262 (if (fboundp 'custom-make-dependencies)
263 (custom-make-dependencies)
264 (Custom-make-dependencies))))
266 (defun dgnushack-make-auto-load ()
268 (unless (make-autoload '(define-derived-mode child parent name
271 (defadvice make-autoload (around handle-define-derived-mode activate)
272 "Handle `define-derived-mode'."
273 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
274 (setq ad-return-value
276 (list 'quote (nth 1 (ad-get-arg 0)))
278 (nth 4 (ad-get-arg 0))
281 (put 'define-derived-mode 'doc-string-elt 3))
282 (let ((generated-autoload-file dgnushack-gnus-load-file)
283 (make-backup-files nil)
284 (autoload-package-name "gnus"))
285 (if (featurep 'xemacs)
286 (if (file-exists-p generated-autoload-file)
287 (delete-file generated-autoload-file))
288 (with-temp-file generated-autoload-file
290 (batch-update-autoloads)))
292 (defun dgnushack-make-load ()
293 (message "Generating %s..." dgnushack-gnus-load-file)
294 (with-temp-file dgnushack-gnus-load-file
295 (insert-file-contents dgnushack-cus-load-file)
296 (delete-file dgnushack-cus-load-file)
297 (goto-char (point-min))
298 (search-forward ";;; Code:")
300 (delete-region (point-min) (point))
302 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
306 (goto-char (point-max))
307 (if (search-backward "custom-versions-load-alist" nil t)
310 (while (eq (char-after) ?\;)
313 (delete-region (point) (point-max))
315 ;; smiley-* are duplicated. Remove them all.
316 (let ((point (point)))
317 (insert-file-contents dgnushack-gnus-load-file)
319 (while (search-forward "smiley-" nil t)
321 (if (looking-at "(autoload ")
322 (delete-region (point) (progn (forward-sexp) (point)))
325 (goto-char (point-max))
326 (when (search-backward "\n(provide " nil t)
328 (delete-region (point) (point-max)))
331 \(provide 'gnus-load)
334 ;;; version-control: never
335 ;;; no-byte-compile: t
336 ;;; no-update-autoloads: t
338 ;;; gnus-load.el ends here
340 ;; Workaround the bug in some version of XEmacs.
341 (when (featurep 'xemacs)
345 (goto-char (point-min))
346 (when (and (fboundp 'custom-add-loads)
347 (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
348 (search-forward "\n;;; Code:" nil t)
350 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
351 (message "Compiling %s..." dgnushack-gnus-load-file)
352 (byte-compile-file dgnushack-gnus-load-file))
354 ;;; dgnushack.el ends here