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
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 (autoload 'Info-directory "info" nil t)
477 (autoload 'Info-menu "info" nil t)
478 (autoload 'annotations-at "annotations")
479 (autoload 'apropos "apropos" nil t)
480 (autoload 'apropos-command "apropos" nil t)
481 (autoload 'bbdb-complete-name "bbdb-com" nil t)
482 (autoload 'browse-url "browse-url" nil t)
483 (autoload 'customize-apropos "cus-edit" nil t)
484 (autoload 'customize-save-variable "cus-edit" nil t)
485 (autoload 'customize-variable "cus-edit" nil t)
486 (autoload 'delete-annotation "annotations")
487 (autoload 'dolist "cl-macs" nil nil 'macro)
488 (autoload 'enriched-decode "enriched")
489 (autoload 'info "info" nil t)
490 (autoload 'make-annotation "annotations")
491 (autoload 'make-display-table "disp-table")
493 (autoload 'ps-despool "ps-print" nil t)
494 (autoload 'ps-spool-buffer "ps-print" nil t)
495 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
496 (autoload 'read-passwd "passwd")
497 (autoload 'regexp-opt "regexp-opt")
498 (autoload 'reporter-submit-bug-report "reporter")
499 (if (emacs-version>= 21 5)
500 (autoload 'setenv "process" nil t)
501 (autoload 'setenv "env" nil t))
502 (autoload 'smtpmail-send-it "smtpmail")
503 (autoload 'sort-numeric-fields "sort" nil t)
504 (autoload 'sort-subr "sort")
505 (autoload 'trace-function-background "trace" nil t)
506 (autoload 'w3-do-setup "w3")
507 (autoload 'w3-prepare-buffer "w3-display")
508 (autoload 'w3-region "w3-display" nil t)
509 (defalias 'frame-char-height 'frame-height)
510 (defalias 'frame-char-width 'frame-width)
511 (defalias 'frame-parameter 'frame-property)
512 (defalias 'make-overlay 'ignore)
513 (defalias 'overlay-end 'ignore)
514 (defalias 'overlay-get 'ignore)
515 (defalias 'overlay-put 'ignore)
516 (defalias 'overlay-start 'ignore)
517 (defalias 'overlays-in 'ignore)
518 (defalias 'replace-dehighlight 'ignore)
519 (defalias 'replace-highlight 'ignore)
520 (defalias 'run-with-idle-timer 'ignore)
521 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
525 (when (featurep 'xemacs)
526 (autoload 'c-mode "cc-mode" nil t)
527 (autoload 'font-lock-mode "font-lock" nil t)
528 (autoload 'read-kbd-macro "edmacro" nil t)
529 (autoload 'turn-on-font-lock "font-lock" nil t))
530 (autoload 'nnheader-detect-coding-region "nnheader")
531 (autoload 'std11-extract-addresses-components "nnheader")
532 (autoload 'std11-fold-region "nnheader")
533 (autoload 'std11-narrow-to-field "nnheader")
534 (autoload 'std11-unfold-region "nnheader"))
536 (defconst dgnushack-unexporting-files
537 (append '("dgnushack.el" "dgnuspath.el" "dgnuskwds.el" "lpath.el")
539 (progn (require 'shimbun) nil)
540 (error '("nnshimbun.el")))
541 (unless (or (condition-case code
544 (message "No w3: %s%s, retrying..."
545 (error-message-string code)
546 (if (setq code (locate-library "w3-parse"))
547 (concat " (" code ")")
550 ;; Maybe mis-configured Makefile is used (e.g.
551 ;; configured for FSFmacs but XEmacs is running).
552 (let ((lp (delete dgnushack-w3-directory
553 (copy-sequence load-path))))
554 (if (let ((load-path lp))
558 ;; If success, fix `load-path' for compiling.
561 (message " => fixed; W3DIR=%s"
563 (locate-library "w3-parse")))
565 (message " => ignored")
567 '("nnultimate.el" "webmail.el" "nnwfm.el"))
569 (progn (require 'mh-e) nil)
571 (message "No mh-e: %s%s (ignored)"
572 (error-message-string code)
573 (if (setq code (locate-library "mh-e"))
574 (concat " (" code ")")
578 (progn (require 'xml) nil)
580 (message "No xml: %s%s (ignored)"
581 (error-message-string code)
582 (if (setq code (locate-library "xml"))
583 (concat " (" code ")")
587 (progn (require 'bbdb) nil)
589 (message "No bbdb: %s%s (ignored)"
590 (error-message-string code)
591 (if (setq code (locate-library "bbdb"))
592 (concat " (" code ")")
595 (unless (featurep 'xemacs)
596 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el"))
597 (when (and (not (featurep 'xemacs))
598 (<= emacs-major-version 20))
600 (when (and (fboundp 'base64-decode-string)
601 (subrp (symbol-function 'base64-decode-string)))
603 (when (and (fboundp 'md5) (subrp (symbol-function 'md5)))
605 (unless (boundp 'MULE)
607 "Files which will not be installed.")
609 (defconst dgnushack-exporting-files
610 (let ((files (directory-files srcdir nil "^[^=].*\\.el$" t)))
611 (dolist (file dgnushack-unexporting-files)
612 (setq files (delete file files)))
613 (sort files 'string-lessp))
614 "Files which will be compiled and installed.")
616 (defun dgnushack-exporting-files ()
617 "Print name of files which will be installed."
618 (princ (mapconcat 'identity dgnushack-exporting-files " ")))
620 (defconst dgnushack-dont-compile-files
621 '("mm-bodies.el" "mm-decode.el" "mm-encode.el" "mm-extern.el"
622 "mm-partial.el" "mm-url.el" "mm-uu.el" "mm-view.el" "mml-sec.el"
623 "mml-smime.el" "mml.el" "mml1991.el" "mml2015.el")
624 "Files which should not be byte-compiled.")
626 (defun dgnushack-compile-verbosely ()
627 "Call dgnushack-compile with warnings ENABLED. If you are compiling
628 patches to gnus, you should consider modifying make.bat to call
629 dgnushack-compile-verbosely. All other users should continue to use
631 (dgnushack-compile t))
633 (defun dgnushack-compile-verbosely ()
634 "Call dgnushack-compile with warnings ENABLED. If you are compiling
635 patches to gnus, you should consider modifying make.bat to call
636 dgnushack-compile-verbosely. All other users should continue to use
638 (dgnushack-compile t))
640 (defun dgnushack-compile (&optional warn)
641 ;;(setq byte-compile-dynamic t)
643 (setq byte-compile-warnings
644 '(free-vars unresolved callargs redefine)))
645 (unless (locate-library "cus-edit")
646 (error "You do not seem to have Custom installed.
647 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
648 You also then need to add the following to the lisp/dgnushack.el file:
650 (push \"~/lisp/custom\" load-path)
652 Modify to suit your needs."))
655 (message "load-path=(\"%s\")"
656 (mapconcat 'identity load-path "\"\n \""))
658 (dolist (file dgnushack-exporting-files)
659 (setq file (expand-file-name file srcdir))
660 (when (and (file-exists-p
661 (setq elc (concat (file-name-nondirectory file) "c")))
662 (file-newer-than-file-p file elc))
665 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
667 (when (featurep 'xemacs)
668 (setq gnus-xmas-glyph-directory "dummy"))
670 (let ((files dgnushack-exporting-files)
671 ;;(byte-compile-generate-call-tree t)
673 (while (setq file (pop files))
674 (unless (member file dgnushack-dont-compile-files)
675 (setq file (expand-file-name file srcdir))
676 (when (or (not (file-exists-p
677 (setq elc (concat (file-name-nondirectory file) "c"))))
678 (file-newer-than-file-p file elc))
680 (byte-compile-file file)))))))
682 (defun dgnushack-recompile ()
684 (byte-recompile-directory "." 0))
686 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el" srcdir))
687 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el" srcdir))
688 (defvar dgnushack-auto-load-file (expand-file-name "auto-autoloads.el" srcdir))
690 (defun dgnushack-make-cus-load ()
691 (when (condition-case nil
694 (let ((cusload-base-file dgnushack-cus-load-file))
695 (if (fboundp 'custom-make-dependencies)
696 (custom-make-dependencies)
697 (Custom-make-dependencies)))))
699 (defun dgnushack-make-auto-load ()
701 (unless (make-autoload '(define-derived-mode child parent name
704 (defadvice make-autoload (around handle-define-derived-mode activate)
705 "Handle `define-derived-mode'."
706 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
707 (setq ad-return-value
709 (list 'quote (nth 1 (ad-get-arg 0)))
711 (nth 4 (ad-get-arg 0))
714 (put 'define-derived-mode 'doc-string-elt 3))
715 (let ((generated-autoload-file dgnushack-gnus-load-file)
716 (make-backup-files nil)
717 (autoload-package-name "gnus"))
718 (if (featurep 'xemacs)
720 (if (file-exists-p generated-autoload-file)
721 (delete-file generated-autoload-file))
722 (if (file-exists-p dgnushack-auto-load-file)
723 (delete-file dgnushack-auto-load-file)))
724 (with-temp-file generated-autoload-file
726 (if (featurep 'xemacs)
727 (let ((si:message (symbol-function 'message)))
728 (defun message (fmt &rest args)
729 (cond ((and (string-equal "Generating autoloads for %s..." fmt)
730 (file-exists-p (file-name-nondirectory (car args))))
732 fmt (file-name-nondirectory (car args))))
733 ((string-equal "No autoloads found in %s" fmt))
734 ((string-equal "Generating autoloads for %s...done" fmt))
735 (t (apply si:message fmt args))))
737 (batch-update-autoloads)
738 (fset 'message si:message)))
739 (batch-update-autoloads))))
741 (defun dgnushack-make-load ()
742 (message (format "Generating %s..." dgnushack-gnus-load-file))
743 (with-temp-file dgnushack-gnus-load-file
744 (if (file-exists-p dgnushack-cus-load-file)
746 (insert-file-contents dgnushack-cus-load-file)
747 (delete-file dgnushack-cus-load-file)
748 (goto-char (point-min))
749 (search-forward ";;; Code:")
751 (delete-region (point-min) (point))
752 (unless (re-search-forward "\
753 ^[\t ]*(autoload[\t\n ]+\\('\\|(quote[\t\n ]+\\)custom-add-loads[\t\n ]"
755 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))
756 (goto-char (point-min))
758 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
762 (goto-char (point-max))
763 (if (search-backward "custom-versions-load-alist" nil t)
766 (while (eq (char-after) ?\;)
769 (delete-region (point) (point-max))
772 ;;; gnus-load.el --- automatically extracted autoload
776 ;; smiley-* are duplicated. Remove them all.
777 (let ((point (point)))
778 (insert-file-contents dgnushack-gnus-load-file)
780 (while (search-forward "smiley-" nil t)
782 (if (looking-at "(autoload ")
783 (delete-region (point) (progn (forward-sexp) (point)))
786 (goto-char (point-max))
787 (when (search-backward "\n(provide " nil t)
789 (delete-region (point) (point-max)))
792 \(provide 'gnus-load)
795 ;;; version-control: never
796 ;;; no-byte-compile: t
797 ;;; no-update-autoloads: t
799 ;;; gnus-load.el ends here
801 ;; Workaround the bug in some version of XEmacs.
802 (when (featurep 'xemacs)
806 (goto-char (point-min))
807 (when (and (fboundp 'custom-add-loads)
808 (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
809 (search-forward "\n;;; Code:" nil t)
811 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
812 (message (format "Compiling %s..." dgnushack-gnus-load-file))
813 (byte-compile-file dgnushack-gnus-load-file))
816 (defun dgnushack-compose-package ()
817 "Re-split the file gnus-load.el into custom-load.el and
818 auto-autoloads.el. It is silly, should be improved!"
820 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...")
821 (let ((customload (expand-file-name "custom-load.el" srcdir))
822 (autoloads (expand-file-name "auto-autoloads.el" srcdir))
825 (insert-file-contents dgnushack-gnus-load-file)
826 (delete-file dgnushack-gnus-load-file)
827 (when (file-exists-p (concat dgnushack-gnus-load-file "c"))
828 (delete-file (concat dgnushack-gnus-load-file "c")))
830 (looking-at "[\t ;]")
834 ;;; custom-load.el --- automatically extracted custom dependencies\n
836 (goto-char (point-max))
839 (not (looking-at "[\t ]*(custom-add-loads[\t\n ]"))))
842 (insert "\n;;; custom-load.el ends here\n")
843 (write-region start (point) customload)
844 (while (looking-at "[\t ]*$")
847 (if (re-search-forward "^[\t\n ]*(if[\t\n ]+(featurep[\t\n ]" nil t)
848 (let ((from (goto-char (match-beginning 0))))
849 (delete-region from (progn
853 (while (looking-at "[\t ;]")
855 (insert "(if (featurep 'gnus-autoloads) (error \"Already loaded\"))\n")
856 (goto-char (point-max))
859 (not (looking-at "[\t ]*(provide[\t\n ]"))))
860 (insert "(provide 'gnus-autoloads)\n")
861 (write-region start (point) autoloads))
862 (byte-compile-file customload)
863 (byte-compile-file autoloads))
865 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...done
869 (defconst dgnushack-info-file-regexp-en
870 (let ((names '("gnus" "message" "emacs-mime"))
872 (while (setq name (pop names))
873 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
874 (when names "\\|"))))
876 "Regexp matching English info files.")
878 (defconst dgnushack-info-file-regexp-ja
879 (let ((names '("gnus-ja" "message-ja"))
881 (while (setq name (pop names))
882 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
883 (when names "\\|"))))
885 "Regexp matching Japanese info files.")
887 (defun dgnushack-remove-extra-files-in-package ()
888 "Remove extra files in the lisp directory of the XEmacs package."
889 (let ((lisp-dir (expand-file-name (concat "lisp/"
891 (cadr command-line-args-left)
894 (car command-line-args-left))))
895 (setq command-line-args-left nil)
896 (when (file-directory-p lisp-dir)
898 (dolist (file dgnushack-exporting-files)
899 (setq files (nconc files (list file (concat file "c")))))
900 (dolist (file (directory-files lisp-dir nil nil t t))
901 (unless (member file files)
902 (setq file (expand-file-name file lisp-dir))
903 (message "Removing %s..." file)
908 (defun dgnushack-install-package-manifest ()
909 "Install MANIFEST file as an XEmacs package."
910 (let* ((package-dir (pop command-line-args-left))
911 (product-name (pop command-line-args-left))
912 (pkginfo-dir (expand-file-name "pkginfo" package-dir))
913 (name (expand-file-name (concat "MANIFEST." product-name)
916 (unless (file-directory-p pkginfo-dir)
917 (message "Creating directory %s/..." pkginfo-dir)
918 (make-directory pkginfo-dir))
919 (message "Generating %s..." name)
921 (insert "pkginfo/MANIFEST." product-name "\n")
922 (let ((lisp-dir (concat "lisp/" product-name "/"))
923 (files (sort (directory-files "." nil "\\.elc?$" t) 'string-lessp))
925 (while (setq file (pop files))
926 (unless (member file dgnushack-unexporting-files)
927 (insert lisp-dir file "\n")))
929 (sort (directory-files "../texi/" nil
930 (concat dgnushack-info-file-regexp-en
932 dgnushack-info-file-regexp-ja)
935 (while (setq file (pop files))
936 (insert "info/" file "\n"))))))
939 (define-compiler-macro describe-key-briefly (&whole form key &optional insert)
940 (if (condition-case nil
942 (describe-key-briefly '((())) nil)
944 (wrong-number-of-arguments nil);; Old Emacsen.
949 (insert (funcall 'describe-key-briefly ,key))
950 (funcall 'describe-key-briefly ,key))
951 `(funcall 'describe-key-briefly ,key))))
953 ;;; dgnushack.el ends here