1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Katsumi Yamaoka <yamaoka@jpl.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 ;; Set coding priority of Shift-JIS to the bottom.
32 (if (featurep 'xemacs)
33 (defalias 'set-coding-priority 'ignore)
34 (defalias 'coding-priority-list 'ignore)
35 (defalias 'set-coding-priority-list 'ignore))
36 (cond ((and (featurep 'xemacs) (featurep 'mule))
37 (if (memq 'shift-jis (coding-priority-list))
38 (set-coding-priority-list
39 (append (delq 'shift-jis (coding-priority-list)) '(shift-jis)))))
41 (put '*coding-category-sjis* 'priority (length *predefined-category*)))
43 (if (memq 'coding-category-sjis coding-category-list)
45 (append (delq 'coding-category-sjis
46 (copy-sequence coding-category-list))
47 '(coding-category-sjis))))))
49 (defalias 'facep 'ignore)
54 ;; `dolist' might not be available because of ``-no-autoloads''.
56 ;; It may have been defined in egg.el.
58 (load "cl-macs" nil t))
60 (defvar srcdir (or (getenv "srcdir") "."))
62 (defvar dgnushack-w3-directory (let ((w3dir (getenv "W3DIR")))
63 (unless (zerop (length w3dir))
64 (file-name-as-directory w3dir))))
66 (let ((urldir (getenv "URLDIR")))
67 (unless (zerop (length urldir))
68 (setq urldir (file-name-as-directory urldir))
69 (push (file-name-as-directory urldir) load-path))
70 (when (and dgnushack-w3-directory
71 (not (string-equal urldir dgnushack-w3-directory)))
72 (push dgnushack-w3-directory load-path)))
74 ;; If we are building w3 in a different directory than the source
75 ;; directory, we must read *.el from source directory and write *.elc
76 ;; into the building directory. For that, we define this function
77 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
78 (defun byte-compile-dest-file (filename)
79 "Convert an Emacs Lisp source file name to a compiled file name.
80 In addition, remove directory name part from FILENAME."
81 (setq filename (byte-compiler-base-file-name filename))
82 (setq filename (file-name-sans-versions filename))
83 (setq filename (file-name-nondirectory filename))
84 (if (memq system-type '(win32 w32 mswindows windows-nt))
85 (setq filename (downcase filename)))
86 (cond ((eq system-type 'vax-vms)
87 (concat (substring filename 0 (string-match ";" filename)) "c"))
88 ((string-match emacs-lisp-file-regexp filename)
89 (concat (substring filename 0 (match-beginning 0)) ".elc"))
90 (t (concat filename ".elc"))))
93 ;; To avoid having defsubsts and inlines happen.
94 ;(if (featurep 'xemacs)
95 ; (require 'byte-optimize)
96 ; (require 'byte-opt))
97 ;(defun byte-optimize-inline-handler (form)
98 ; "byte-optimize-handler for the `inline' special-form."
99 ; (cons 'progn (cdr form)))
100 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
103 (let (current-load-list)
104 ;; Make the function to be silent at compile-time.
105 (defun locate-library (library &optional nosuffix)
106 "Show the full path name of Emacs library LIBRARY.
107 This command searches the directories in `load-path' like `M-x load-library'
108 to find the file that `M-x load-library RET LIBRARY RET' would load.
109 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
110 to the specified name LIBRARY (a la calling `load' instead of `load-library')."
111 (interactive "sLocate library: ")
117 (let ((try (expand-file-name (concat library suf) dir)))
118 (and (file-readable-p try)
119 (null (file-directory-p try))
122 (message "Library is file %s" try))
123 (throw 'answer try)))))
124 (if nosuffix '("") '(".elc" ".el" ""))))
127 (message "No library %s in search path" library))
129 (byte-compile 'locate-library)))
131 (setq max-specpdl-size 3000)
138 (message "The subform `(< 0 1)' should be optimized to t"))
141 (defadvice byte-optimize-form-code-walker
142 (around fix-bug-in-and/or-forms (form for-effect) activate)
143 "Fix a bug in the optimizing and/or forms.
144 It has already been fixed in XEmacs since 1999-12-06."
145 (if (and for-effect (memq (car-safe form) '(and or)))
146 (let ((fn (car form))
147 (backwards (reverse (cdr form))))
148 (while (and backwards
149 (null (setcar backwards
150 (byte-optimize-form (car backwards) t))))
151 (setq backwards (cdr backwards)))
152 (if (and (cdr form) (null backwards))
154 " all subforms of %s called for effect; deleted" form))
157 (mapcar 'byte-optimize-form (cdr backwards))))
158 (setq ad-return-value (cons fn (nreverse backwards))))
163 (wrong-number-of-arguments
164 ;; Optimize byte code for `char-after'.
165 (put 'char-after 'byte-optimizer 'byte-optimize-char-after)
166 (defun byte-optimize-char-after (form)
167 (if (null (cdr form))
168 '(char-after (point))
173 (wrong-number-of-arguments
174 ;; Optimize byte code for `char-before'.
175 (put 'char-before 'byte-optimizer 'byte-optimize-char-before)
176 (defun byte-optimize-char-before (form)
177 (if (null (cdr form))
178 '(char-before (point))
181 (load (expand-file-name "dgnuspath.el" srcdir) nil nil t)
184 (load "~/.lpath.el" t nil t)
185 (error (message "Error in \"~/.lpath.el\" file: %s" err)))
187 ;; Don't load path-util until `char-after' and `char-before' have been
188 ;; optimized because it requires `poe' and then modify the functions.
190 ;; If the APEL modules are installed under the non-standard directory,
191 ;; for example "/var/home/john/lisp/apel-VERSION/", you should add that
192 ;; name using the configure option "--with-addpath=".
193 ;; And also the directory where the EMU modules are installed, for
194 ;; example "/usr/local/share/mule/19.34/site-lisp/", it should be
195 ;; included in the standard `load-path' or added by the configure
196 ;; option "--with-addpath=".
197 (let ((path (or (locate-library "path-util")
198 (locate-library "apel/path-util")));; backward compat.
202 (when (string-match "/$" (setq path (file-name-directory path)))
203 (setq path (substring path 0 (match-beginning 0))))
204 ;; path == "/var/home/john/lisp/apel-VERSION"
205 (when (string-match "/$" (setq parent (file-name-directory path)))
206 (setq parent (substring path 0 (match-beginning 0))))
207 ;; parent == "/var/home/john/lisp"
208 (if (setq lpath (or (member path load-path)
209 (member (file-name-as-directory path) load-path)))
210 (unless (or (member parent load-path)
211 (member (file-name-as-directory parent) load-path))
212 (push parent (cdr lpath)))
213 (push path load-path)
214 (unless (or (member parent load-path)
215 (member (file-name-as-directory parent) load-path))
216 (push parent (cdr load-path))))
218 (require 'path-util))
220 APEL modules are not found in %s.
221 Try to re-configure with --with-addpath=APEL_PATH and run make again.
225 (unless (locate-library "mel")
227 (unless (module-installed-p 'mel)
228 ;; FLIM 1.14 may have installed in two "flim" subdirectories.
229 (push (expand-file-name "flim"
230 (file-name-directory (get-latest-path "^apel$" t)))
232 (unless (module-installed-p 'mel)
234 FLIM modules does not found in %s.
235 Try to re-configure with --with-addpath=FLIM_PATH and run make again.
240 (push srcdir load-path)
241 (load (expand-file-name "lpath.el" srcdir) nil t t)
243 (load (expand-file-name "gnus-clfns.el" srcdir) nil t t)
246 ;; Bind the function `base64-encode-string' before loading canlock.
247 ;; Since canlock will bind it as an autoloaded function, it causes
248 ;; damage to define the function by MEL.
249 (load (expand-file-name "base64.el" srcdir) nil t t)
250 ;; Load special macros for compiling canlock.el.
251 (load (expand-file-name "canlock-om.el" srcdir) nil t t))
255 ;; Bind functions defined by `defun-maybe'.
256 (put 'defun-maybe 'byte-hunk-handler 'byte-compile-file-form-defun-maybe)
257 (defun byte-compile-file-form-defun-maybe (form)
258 (if (and (not (fboundp (nth 1 form)))
259 (memq 'unresolved byte-compile-warnings))
260 (setq byte-compile-function-environment
261 (cons (cons (nth 1 form)
262 (cons 'lambda (cdr (cdr form))))
263 byte-compile-function-environment)))
267 :symbol-for-testing-whether-colon-keyword-is-available-or-not
269 (defun dgnushack-bind-colon-keywords ()
270 "Bind all the colon keywords for old Emacsen."
271 (let ((cache (expand-file-name "dgnuskwds.el" srcdir))
272 (makefile (expand-file-name "Makefile" srcdir))
273 (buffer (get-buffer-create " *colon keywords*"))
274 keywords ignores files file dirs dir form elem make-backup-files)
277 (let (buffer-file-format
279 insert-file-contents-post-hook
280 insert-file-contents-pre-hook
281 jam-zcat-filename-list
282 jka-compr-compression-info-list)
283 (if (and (file-exists-p cache)
284 (file-exists-p makefile)
285 (file-newer-than-file-p cache makefile))
287 (insert-file-contents cache nil nil nil t)
288 (setq keywords (read buffer)))
291 '(:symbol-for-testing-whether-colon-keyword-is-available-or-not
292 ;; The following keywords will be bound by CUSTOM.
293 :get :group :initialize :link :load :options :prefix
294 :require :set :tag :type)
295 files (list (locate-library "semi-def")
296 (locate-library "mailcap")
297 (locate-library "mime-def")
298 (locate-library "path-util")
299 (locate-library "poem"))
300 dirs (list (file-name-as-directory (expand-file-name srcdir))))
302 (when (setq file (pop files))
303 (setq dir (file-name-directory file))
304 (unless (member dir dirs)
306 (message "Searching for all the colon keywords in:")
308 (setq dir (pop dirs))
309 (message " %s..." dir)
310 (setq files (directory-files dir t
311 "\\.el\\(\\.gz\\|\\.bz2\\)?$"))
313 (setq file (pop files))
314 (if (string-match "\\(\\.gz$\\)\\|\\.bz2$" file)
315 (let ((temp (expand-file-name "dgnustemp.el" srcdir)))
317 (let* ((binary (if (boundp 'MULE)
320 (coding-system-for-read binary)
321 (coding-system-for-write binary)
322 (input-coding-system binary)
323 (output-coding-system binary)
324 (default-process-coding-system
325 (cons binary binary))
327 (insert-file-contents file nil nil nil t)
331 (if (match-beginning 1)
333 (point-min) (point-max)
334 "gzip" t buffer nil "-cd")
336 (point-min) (point-max)
337 "bzip2" t buffer nil "-d"))
341 (message "In file %s: %s" file code)
343 (write-region (point-min) (point-max) temp
347 (insert-file-contents temp nil nil nil t)
348 (delete-file temp))))
349 (insert-file-contents file nil nil nil t))
350 (while (setq form (condition-case nil
355 (setq elem (car-safe form)
356 form (cdr-safe form))
357 (unless (memq (car-safe elem)
358 '(defcustom defface defgroup
359 define-widget quote))
361 (push (car elem) form)
362 (setq elem (cdr elem)))
366 (eq ?: (aref (symbol-name elem) 0))
367 (not (memq elem ignores))
368 (not (memq elem keywords)))
369 (push elem keywords))))))))
370 (setq keywords (sort keywords
372 (string-lessp (symbol-name a)
375 (insert (format "%s" keywords))
376 (write-region (point-min) (point) cache nil 'silent)
378 "The following colon keywords will be bound at run-time:\n %s"
381 (defconst dgnushack-colon-keywords keywords)
383 (set (car keywords) (car keywords))
384 (setq keywords (cdr keywords)))))
385 (byte-compile 'dgnushack-bind-colon-keywords)
386 (dgnushack-bind-colon-keywords)))
389 (setq :version ':version
390 :set-after ':set-after)
392 (defadvice custom-handle-keyword
393 (around dont-signal-an-error-even-if-unsupported-keyword-is-given
395 "Don't signal an error even if unsupported keyword is given."
396 (if (not (memq (ad-get-arg 1) '(:version :set-after)))
400 (put 'custom-declare-face 'byte-optimizer
401 'byte-optimize-ignore-unsupported-custom-keywords)
402 (put 'custom-declare-group 'byte-optimizer
403 'byte-optimize-ignore-unsupported-custom-keywords)
404 (defun byte-optimize-ignore-unsupported-custom-keywords (form)
405 (if (or (memq ':version (nthcdr 4 form))
406 (memq ':set-after (nthcdr 4 form)))
407 (let ((newform (list (car form) (nth 1 form)
408 (nth 2 form) (nth 3 form)))
409 (args (nthcdr 4 form)))
411 (or (memq (car args) '(:version :set-after))
412 (setq newform (nconc newform (list (car args)
414 (setq args (cdr (cdr args))))
418 (put 'custom-declare-variable 'byte-hunk-handler
419 'byte-compile-file-form-custom-declare-variable)
420 (defun byte-compile-file-form-custom-declare-variable (form)
421 ;; Bind defcustom'ed variables.
422 (if (memq 'free-vars byte-compile-warnings)
423 (setq byte-compile-bound-variables
424 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
425 (if (memq ':version (nthcdr 4 form))
426 ;; Make the variable uncustomizable.
427 `(defvar ,(nth 1 (nth 1 form)) ,(nth 1 (nth 2 form))
428 ,(substring (nth 3 form) (if (string-match "^[\t *]+" (nth 3 form))
431 ;; Ignore unsupported keyword(s).
432 (if (memq ':set-after (nthcdr 4 form))
433 (let ((newform (list (car form) (nth 1 form)
434 (nth 2 form) (nth 3 form)))
435 (args (nthcdr 4 form)))
437 (or (eq (car args) ':set-after)
438 (setq newform (nconc newform (list (car args)
440 (setq args (cdr (cdr args))))
444 (defadvice byte-compile-inline-expand (around ignore-built-in-functions
446 "Ignore built-in functions."
447 (let* ((name (car form))
448 (fn (and (fboundp name)
449 (symbol-function name))))
451 ;; Give up on inlining.
452 (setq ad-return-value form)
455 ;; Unknown variables and functions.
456 (unless (boundp 'buffer-file-coding-system)
457 (defvar buffer-file-coding-system (symbol-value 'file-coding-system)))
458 (unless (featurep 'xemacs)
459 (defalias 'Custom-make-dependencies 'ignore)
460 (defalias 'update-autoloads-from-directory 'ignore))
462 (defalias 'device-sound-enabled-p 'ignore)
463 (defalias 'play-sound-file 'ignore)
464 (defalias 'nndb-request-article 'ignore)
465 (defalias 'efs-re-read-dir 'ignore)
466 (defalias 'ange-ftp-re-read-dir 'ignore)
467 (defalias 'define-mail-user-agent 'ignore)
470 (when (featurep 'xemacs)
471 ;; XEmacs 21.1 needs some extra hand holding
472 (when (eq emacs-minor-version 1)
473 (autoload 'custom-declare-face "cus-face" nil t)
474 (autoload 'cl-compile-time-init "cl-macs" nil t)
475 (autoload 'defadvice "advice" nil nil 'macro))
476 (unless (fboundp 'defadvice)
477 (autoload 'defadvice "advice" nil nil 'macro))
478 (autoload 'Info-directory "info" nil t)
479 (autoload 'Info-menu "info" nil t)
480 (autoload 'annotations-at "annotations")
481 (autoload 'apropos "apropos" nil t)
482 (autoload 'apropos-command "apropos" nil t)
483 (autoload 'bbdb-complete-name "bbdb-com" nil t)
484 (autoload 'browse-url "browse-url" nil t)
485 (autoload 'customize-apropos "cus-edit" nil t)
486 (autoload 'customize-save-variable "cus-edit" nil t)
487 (autoload 'customize-variable "cus-edit" nil t)
488 (autoload 'delete-annotation "annotations")
489 (autoload 'dolist "cl-macs" nil nil 'macro)
490 (autoload 'enriched-decode "enriched")
491 (autoload 'info "info" nil t)
492 (autoload 'make-annotation "annotations")
493 (autoload 'make-display-table "disp-table")
495 (autoload 'ps-despool "ps-print" nil t)
496 (autoload 'ps-spool-buffer "ps-print" nil t)
497 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
498 (autoload 'read-passwd "passwd")
499 (autoload 'regexp-opt "regexp-opt")
500 (autoload 'reporter-submit-bug-report "reporter")
501 (if (emacs-version>= 21 5)
502 (autoload 'setenv "process" nil t)
503 (autoload 'setenv "env" nil t))
504 (autoload 'smtpmail-send-it "smtpmail")
505 (autoload 'sort-numeric-fields "sort" nil t)
506 (autoload 'sort-subr "sort")
507 (autoload 'trace-function-background "trace" nil t)
508 (autoload 'w3-do-setup "w3")
509 (autoload 'w3-prepare-buffer "w3-display")
510 (autoload 'w3-region "w3-display" nil t)
511 (defalias 'frame-char-height 'frame-height)
512 (defalias 'frame-char-width 'frame-width)
513 (defalias 'frame-parameter 'frame-property)
514 (defalias 'make-overlay 'ignore)
515 (defalias 'overlay-end 'ignore)
516 (defalias 'overlay-get 'ignore)
517 (defalias 'overlay-put 'ignore)
518 (defalias 'overlay-start 'ignore)
519 (defalias 'overlays-in 'ignore)
520 (defalias 'replace-dehighlight 'ignore)
521 (defalias 'replace-highlight 'ignore)
522 (defalias 'run-with-idle-timer 'ignore)
523 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
527 (when (featurep 'xemacs)
528 (autoload 'c-mode "cc-mode" nil t)
529 (autoload 'font-lock-mode "font-lock" nil t)
530 (autoload 'read-kbd-macro "edmacro" nil t)
531 (autoload 'turn-on-font-lock "font-lock" nil t))
532 (autoload 'nnheader-detect-coding-region "nnheader")
533 (autoload 'std11-extract-addresses-components "nnheader")
534 (autoload 'std11-fold-region "nnheader")
535 (autoload 'std11-narrow-to-field "nnheader")
536 (autoload 'std11-unfold-region "nnheader"))
538 (defconst dgnushack-unexporting-files
539 (append '("dgnushack.el" "dgnuspath.el" "dgnuskwds.el" "lpath.el")
540 (unless (or (condition-case code
543 (message "No w3: %s%s, retrying..."
544 (error-message-string code)
545 (if (setq code (locate-library "w3-parse"))
546 (concat " (" code ")")
549 ;; Maybe mis-configured Makefile is used (e.g.
550 ;; configured for FSFmacs but XEmacs is running).
551 (let ((lp (delete dgnushack-w3-directory
552 (copy-sequence load-path))))
553 (if (let ((load-path lp))
557 ;; If success, fix `load-path' for compiling.
560 (message " => fixed; W3DIR=%s"
562 (locate-library "w3-parse")))
564 (message " => ignored")
566 '("nnultimate.el" "webmail.el" "nnwfm.el"))
568 (progn (require 'mh-e) nil)
570 (message "No mh-e: %s%s (ignored)"
571 (error-message-string code)
572 (if (setq code (locate-library "mh-e"))
573 (concat " (" code ")")
577 (progn (require 'xml) nil)
579 (message "No xml: %s%s (ignored)"
580 (error-message-string code)
581 (if (setq code (locate-library "xml"))
582 (concat " (" code ")")
586 (progn (require 'bbdb) nil)
588 (message "No bbdb: %s%s (ignored)"
589 (error-message-string code)
590 (if (setq code (locate-library "bbdb"))
591 (concat " (" code ")")
594 (unless (featurep 'xemacs)
595 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el"))
596 (when (and (not (featurep 'xemacs))
597 (<= emacs-major-version 20))
599 (when (and (fboundp 'base64-decode-string)
600 (subrp (symbol-function 'base64-decode-string)))
602 (when (and (fboundp 'md5) (subrp (symbol-function 'md5)))
604 (unless (boundp 'MULE)
606 "Files which will not be installed.")
608 (defconst dgnushack-exporting-files
609 (let ((files (directory-files srcdir nil "^[^=].*\\.el$" t)))
610 (dolist (file dgnushack-unexporting-files)
611 (setq files (delete file files)))
612 (sort files 'string-lessp))
613 "Files which will be compiled and installed.")
615 (defun dgnushack-exporting-files ()
616 "Print name of files which will be installed."
617 (princ (mapconcat 'identity dgnushack-exporting-files " ")))
619 (defconst dgnushack-dont-compile-files
620 '("mm-bodies.el" "mm-decode.el" "mm-encode.el" "mm-extern.el"
621 "mm-partial.el" "mm-url.el" "mm-uu.el" "mm-view.el" "mml-sec.el"
622 "mml-smime.el" "mml.el" "mml1991.el" "mml2015.el")
623 "Files which should not be byte-compiled.")
625 (defun dgnushack-compile-verbosely ()
626 "Call dgnushack-compile with warnings ENABLED. If you are compiling
627 patches to gnus, you should consider modifying make.bat to call
628 dgnushack-compile-verbosely. All other users should continue to use
630 (dgnushack-compile t))
632 (defun dgnushack-compile-verbosely ()
633 "Call dgnushack-compile with warnings ENABLED. If you are compiling
634 patches to gnus, you should consider modifying make.bat to call
635 dgnushack-compile-verbosely. All other users should continue to use
637 (dgnushack-compile t))
639 (defun dgnushack-compile (&optional warn)
640 ;;(setq byte-compile-dynamic t)
642 (setq byte-compile-warnings
643 '(free-vars unresolved callargs redefine)))
644 (unless (locate-library "cus-edit")
645 (error "You do not seem to have Custom installed.
646 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
647 You also then need to add the following to the lisp/dgnushack.el file:
649 (push \"~/lisp/custom\" load-path)
651 Modify to suit your needs."))
654 (message "load-path=(\"%s\")"
655 (mapconcat 'identity load-path "\"\n \""))
657 (dolist (file dgnushack-exporting-files)
658 (setq file (expand-file-name file srcdir))
659 (when (and (file-exists-p
660 (setq elc (concat (file-name-nondirectory file) "c")))
661 (file-newer-than-file-p file elc))
664 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
666 (when (featurep 'xemacs)
667 (setq gnus-xmas-glyph-directory "dummy"))
669 (let ((files dgnushack-exporting-files)
670 ;;(byte-compile-generate-call-tree t)
672 (while (setq file (pop files))
673 (unless (member file dgnushack-dont-compile-files)
674 (setq file (expand-file-name file srcdir))
675 (when (or (not (file-exists-p
676 (setq elc (concat (file-name-nondirectory file) "c"))))
677 (file-newer-than-file-p file elc))
679 (byte-compile-file file)))))))
681 (defun dgnushack-recompile ()
683 (byte-recompile-directory "." 0))
685 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el" srcdir))
686 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el" srcdir))
687 (defvar dgnushack-auto-load-file (expand-file-name "auto-autoloads.el" srcdir))
689 (defun dgnushack-make-cus-load ()
690 (when (condition-case nil
693 (let ((cusload-base-file dgnushack-cus-load-file))
694 (if (fboundp 'custom-make-dependencies)
695 (custom-make-dependencies)
696 (Custom-make-dependencies)))))
698 (defun dgnushack-make-auto-load ()
700 (unless (make-autoload '(define-derived-mode child parent name
703 (defadvice make-autoload (around handle-define-derived-mode activate)
704 "Handle `define-derived-mode'."
705 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
706 (setq ad-return-value
708 (list 'quote (nth 1 (ad-get-arg 0)))
710 (nth 4 (ad-get-arg 0))
713 (put 'define-derived-mode 'doc-string-elt 3))
714 (let ((generated-autoload-file dgnushack-gnus-load-file)
715 (make-backup-files nil)
716 (autoload-package-name "gnus"))
717 (if (featurep 'xemacs)
719 (if (file-exists-p generated-autoload-file)
720 (delete-file generated-autoload-file))
721 (if (file-exists-p dgnushack-auto-load-file)
722 (delete-file dgnushack-auto-load-file)))
723 (with-temp-file generated-autoload-file
725 (if (featurep 'xemacs)
726 (let ((si:message (symbol-function 'message)))
727 (defun message (fmt &rest args)
728 (cond ((and (string-equal "Generating autoloads for %s..." fmt)
729 (file-exists-p (file-name-nondirectory (car args))))
731 fmt (file-name-nondirectory (car args))))
732 ((string-equal "No autoloads found in %s" fmt))
733 ((string-equal "Generating autoloads for %s...done" fmt))
734 (t (apply si:message fmt args))))
736 (batch-update-autoloads)
737 (fset 'message si:message)))
738 (batch-update-autoloads))))
740 (defun dgnushack-make-load ()
741 (message "Generating %s..." dgnushack-gnus-load-file)
742 (with-temp-file dgnushack-gnus-load-file
743 (if (file-exists-p dgnushack-cus-load-file)
745 (insert-file-contents dgnushack-cus-load-file)
746 (delete-file dgnushack-cus-load-file)
747 (goto-char (point-min))
748 (search-forward ";;; Code:")
750 (delete-region (point-min) (point))
751 (unless (re-search-forward "\
752 ^[\t ]*(autoload[\t\n ]+\\('\\|(quote[\t\n ]+\\)custom-add-loads[\t\n ]"
754 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))
755 (goto-char (point-min))
757 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
761 (goto-char (point-max))
762 (if (search-backward "custom-versions-load-alist" nil t)
765 (while (eq (char-after) ?\;)
768 (delete-region (point) (point-max))
771 ;;; gnus-load.el --- automatically extracted autoload
775 ;; smiley-* are duplicated. Remove them all.
776 (let ((point (point)))
777 (insert-file-contents dgnushack-gnus-load-file)
779 (while (search-forward "smiley-" nil t)
781 (if (looking-at "(autoload ")
782 (delete-region (point) (progn (forward-sexp) (point)))
785 (goto-char (point-max))
786 (when (search-backward "\n(provide " nil t)
788 (delete-region (point) (point-max)))
791 \(provide 'gnus-load)
794 ;;; version-control: never
795 ;;; no-byte-compile: t
796 ;;; no-update-autoloads: t
798 ;;; gnus-load.el ends here
800 ;; Workaround the bug in some version of XEmacs.
801 (when (featurep 'xemacs)
805 (goto-char (point-min))
806 (when (and (fboundp 'custom-add-loads)
807 (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
808 (search-forward "\n;;; Code:" nil t)
810 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
811 (message "Compiling %s..." dgnushack-gnus-load-file)
812 (byte-compile-file dgnushack-gnus-load-file))
815 (defun dgnushack-compose-package ()
816 "Re-split the file gnus-load.el into custom-load.el and
817 auto-autoloads.el. It is silly, should be improved!"
819 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...")
820 (let ((customload (expand-file-name "custom-load.el" srcdir))
821 (autoloads (expand-file-name "auto-autoloads.el" srcdir))
824 (insert-file-contents dgnushack-gnus-load-file)
825 (delete-file dgnushack-gnus-load-file)
826 (when (file-exists-p (concat dgnushack-gnus-load-file "c"))
827 (delete-file (concat dgnushack-gnus-load-file "c")))
829 (looking-at "[\t ;]")
833 ;;; custom-load.el --- automatically extracted custom dependencies\n
835 (goto-char (point-max))
838 (not (looking-at "[\t ]*(custom-add-loads[\t\n ]"))))
841 (insert "\n;;; custom-load.el ends here\n")
842 (write-region start (point) customload)
843 (while (looking-at "[\t ]*$")
846 (if (re-search-forward "^[\t\n ]*(if[\t\n ]+(featurep[\t\n ]" nil t)
847 (let ((from (goto-char (match-beginning 0))))
848 (delete-region from (progn
852 (while (looking-at "[\t ;]")
854 (insert "(if (featurep 'gnus-autoloads) (error \"Already loaded\"))\n")
855 (goto-char (point-max))
858 (not (looking-at "[\t ]*(provide[\t\n ]"))))
859 (insert "(provide 'gnus-autoloads)\n")
860 (write-region start (point) autoloads))
861 (byte-compile-file customload)
862 (byte-compile-file autoloads))
864 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...done
868 (defconst dgnushack-info-file-regexp-en
869 (let ((names '("gnus" "message" "emacs-mime"))
871 (while (setq name (pop names))
872 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
873 (when names "\\|"))))
875 "Regexp matching English info files.")
877 (defconst dgnushack-info-file-regexp-ja
878 (let ((names '("gnus-ja" "message-ja"))
880 (while (setq name (pop names))
881 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
882 (when names "\\|"))))
884 "Regexp matching Japanese info files.")
886 (defun dgnushack-remove-extra-files-in-package ()
887 "Remove extra files in the lisp directory of the XEmacs package."
888 (let ((lisp-dir (expand-file-name (concat "lisp/"
890 (cadr command-line-args-left)
893 (car command-line-args-left))))
894 (setq command-line-args-left nil)
895 (when (file-directory-p lisp-dir)
897 (dolist (file dgnushack-exporting-files)
898 (setq files (nconc files (list file (concat file "c")))))
899 (dolist (file (directory-files lisp-dir nil nil t t))
900 (unless (member file files)
901 (setq file (expand-file-name file lisp-dir))
902 (message "Removing %s..." file)
907 (defun dgnushack-install-package-manifest ()
908 "Install MANIFEST file as an XEmacs package."
909 (let* ((package-dir (pop command-line-args-left))
910 (product-name (pop command-line-args-left))
911 (pkginfo-dir (expand-file-name "pkginfo" package-dir))
912 (name (expand-file-name (concat "MANIFEST." product-name)
915 (unless (file-directory-p pkginfo-dir)
916 (message "Creating directory %s/..." pkginfo-dir)
917 (make-directory pkginfo-dir))
918 (message "Generating %s..." name)
920 (insert "pkginfo/MANIFEST." product-name "\n")
921 (let ((lisp-dir (concat "lisp/" product-name "/"))
922 (files (sort (directory-files "." nil "\\.elc?$" t) 'string-lessp))
924 (while (setq file (pop files))
925 (unless (member file dgnushack-unexporting-files)
926 (insert lisp-dir file "\n")))
928 (sort (directory-files "../texi/" nil
929 (concat dgnushack-info-file-regexp-en
931 dgnushack-info-file-regexp-ja)
934 (while (setq file (pop files))
935 (insert "info/" file "\n"))))))
938 (define-compiler-macro describe-key-briefly (&whole form key &optional insert)
939 (if (condition-case nil
941 (describe-key-briefly '((())) nil)
943 (wrong-number-of-arguments nil);; Old Emacsen.
948 (insert (funcall 'describe-key-briefly ,key))
949 (funcall 'describe-key-briefly ,key))
950 `(funcall 'describe-key-briefly ,key))))
952 ;;; dgnushack.el ends here