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)
52 (unless (dolist (var nil t))
53 ;; Override the macro `dolist' which may have been defined in egg.el.
54 (load "cl-macs" nil t))
56 (defvar srcdir (or (getenv "srcdir") "."))
58 (defvar dgnushack-w3-directory (let ((w3dir (getenv "W3DIR")))
59 (unless (zerop (length w3dir))
60 (file-name-as-directory w3dir))))
62 (let ((urldir (getenv "URLDIR")))
63 (unless (zerop (length urldir))
64 (setq urldir (file-name-as-directory urldir))
65 (push (file-name-as-directory urldir) load-path))
66 (when (and dgnushack-w3-directory
67 (not (string-equal urldir dgnushack-w3-directory)))
68 (push dgnushack-w3-directory load-path)))
70 ;; If we are building w3 in a different directory than the source
71 ;; directory, we must read *.el from source directory and write *.elc
72 ;; into the building directory. For that, we define this function
73 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
74 (defun byte-compile-dest-file (filename)
75 "Convert an Emacs Lisp source file name to a compiled file name.
76 In addition, remove directory name part from FILENAME."
77 (setq filename (byte-compiler-base-file-name filename))
78 (setq filename (file-name-sans-versions filename))
79 (setq filename (file-name-nondirectory filename))
80 (if (memq system-type '(win32 w32 mswindows windows-nt))
81 (setq filename (downcase filename)))
82 (cond ((eq system-type 'vax-vms)
83 (concat (substring filename 0 (string-match ";" filename)) "c"))
84 ((string-match emacs-lisp-file-regexp filename)
85 (concat (substring filename 0 (match-beginning 0)) ".elc"))
86 (t (concat filename ".elc"))))
89 ;; To avoid having defsubsts and inlines happen.
90 ;(if (featurep 'xemacs)
91 ; (require 'byte-optimize)
92 ; (require 'byte-opt))
93 ;(defun byte-optimize-inline-handler (form)
94 ; "byte-optimize-handler for the `inline' special-form."
95 ; (cons 'progn (cdr form)))
96 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
99 (let (current-load-list)
100 ;; Make the function to be silent at compile-time.
101 (defun locate-library (library &optional nosuffix)
102 "Show the full path name of Emacs library LIBRARY.
103 This command searches the directories in `load-path' like `M-x load-library'
104 to find the file that `M-x load-library RET LIBRARY RET' would load.
105 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
106 to the specified name LIBRARY (a la calling `load' instead of `load-library')."
107 (interactive "sLocate library: ")
113 (let ((try (expand-file-name (concat library suf) dir)))
114 (and (file-readable-p try)
115 (null (file-directory-p try))
118 (message "Library is file %s" try))
119 (throw 'answer try)))))
120 (if nosuffix '("") '(".elc" ".el" ""))))
123 (message "No library %s in search path" library))
125 (byte-compile 'locate-library)))
127 (setq max-specpdl-size 3000)
134 (message "The subform `(< 0 1)' should be optimized to `t'"))
137 (defadvice byte-optimize-form-code-walker
138 (around fix-bug-in-and/or-forms (form for-effect) activate)
139 "Fix a bug in the optimizing and/or forms.
140 It has already been fixed in XEmacs since 1999-12-06."
141 (if (and for-effect (memq (car-safe form) '(and or)))
142 (let ((fn (car form))
143 (backwards (reverse (cdr form))))
144 (while (and backwards
145 (null (setcar backwards
146 (byte-optimize-form (car backwards) t))))
147 (setq backwards (cdr backwards)))
148 (if (and (cdr form) (null backwards))
150 " all subforms of %s called for effect; deleted" form))
153 (mapcar 'byte-optimize-form (cdr backwards))))
154 (setq ad-return-value (cons fn (nreverse backwards))))
159 (wrong-number-of-arguments
160 ;; Optimize byte code for `char-after'.
161 (put 'char-after 'byte-optimizer 'byte-optimize-char-after)
162 (defun byte-optimize-char-after (form)
163 (if (null (cdr form))
164 '(char-after (point))
169 (wrong-number-of-arguments
170 ;; Optimize byte code for `char-before'.
171 (put 'char-before 'byte-optimizer 'byte-optimize-char-before)
172 (defun byte-optimize-char-before (form)
173 (if (null (cdr form))
174 '(char-before (point))
177 (load (expand-file-name "dgnuspath.el" srcdir) nil nil t)
180 (load "~/.lpath.el" t nil t)
181 (error (message "Error in \"~/.lpath.el\" file: %s" err)))
183 ;; Don't load path-util until `char-after' and `char-before' have been
184 ;; optimized because it requires `poe' and then modify the functions.
186 ;; If the APEL modules are installed under the non-standard directory,
187 ;; for example "/var/home/john/lisp/apel-VERSION/", you should add that
188 ;; name using the configure option "--with-addpath=".
189 ;; And also the directory where the EMU modules are installed, for
190 ;; example "/usr/local/share/mule/19.34/site-lisp/", it should be
191 ;; included in the standard `load-path' or added by the configure
192 ;; option "--with-addpath=".
193 (let ((path (or (locate-library "path-util")
194 (locate-library "apel/path-util")));; backward compat.
198 (when (string-match "/$" (setq path (file-name-directory path)))
199 (setq path (substring path 0 (match-beginning 0))))
200 ;; path == "/var/home/john/lisp/apel-VERSION"
201 (when (string-match "/$" (setq parent (file-name-directory path)))
202 (setq parent (substring path 0 (match-beginning 0))))
203 ;; parent == "/var/home/john/lisp"
204 (if (setq lpath (or (member path load-path)
205 (member (file-name-as-directory path) load-path)))
206 (unless (or (member parent load-path)
207 (member (file-name-as-directory parent) load-path))
208 (push parent (cdr lpath)))
209 (push path load-path)
210 (unless (or (member parent load-path)
211 (member (file-name-as-directory parent) load-path))
212 (push parent (cdr load-path))))
213 (require 'path-util))
215 APEL modules are not found in %s.
216 Try to re-configure with --with-addpath=APEL_PATH and run make again.
220 (unless (locate-library "mel")
222 (unless (module-installed-p 'mel)
223 ;; FLIM 1.14 may have installed in two "flim" subdirectories.
224 (push (expand-file-name "flim"
225 (file-name-directory (get-latest-path "^apel$" t)))
227 (unless (module-installed-p 'mel)
229 FLIM modules does not found in %s.
230 Try to re-configure with --with-addpath=FLIM_PATH and run make again.
235 (push srcdir load-path)
236 (load (expand-file-name "lpath.el" srcdir) nil t t)
238 (load (expand-file-name "gnus-clfns.el" srcdir) nil t t)
241 ;; Bind the function `base64-encode-string' before loading canlock.
242 ;; Since canlock will bind it as an autoloaded function, it causes
243 ;; damage to define the function by MEL.
244 (load (expand-file-name "base64.el" srcdir) nil t t)
245 ;; Load special macros for compiling canlock.el.
246 (load (expand-file-name "canlock-om.el" srcdir) nil t t))
250 ;; Bind functions defined by `defun-maybe'.
251 (put 'defun-maybe 'byte-hunk-handler 'byte-compile-file-form-defun-maybe)
252 (defun byte-compile-file-form-defun-maybe (form)
253 (if (and (not (fboundp (nth 1 form)))
254 (memq 'unresolved byte-compile-warnings))
255 (setq byte-compile-function-environment
256 (cons (cons (nth 1 form)
257 (cons 'lambda (cdr (cdr form))))
258 byte-compile-function-environment)))
262 :symbol-for-testing-whether-colon-keyword-is-available-or-not
264 (defun dgnushack-bind-colon-keywords ()
265 "Bind all the colon keywords for old Emacsen."
266 (let ((cache (expand-file-name "dgnuskwds.el" srcdir))
267 (makefile (expand-file-name "Makefile" srcdir))
268 (buffer (get-buffer-create " *colon keywords*"))
269 keywords ignores files file dirs dir form elem make-backup-files)
272 (let (buffer-file-format
274 insert-file-contents-post-hook
275 insert-file-contents-pre-hook
276 jam-zcat-filename-list
277 jka-compr-compression-info-list)
278 (if (and (file-exists-p cache)
279 (file-exists-p makefile)
280 (file-newer-than-file-p cache makefile))
282 (insert-file-contents cache nil nil nil t)
283 (setq keywords (read buffer)))
286 '(:symbol-for-testing-whether-colon-keyword-is-available-or-not
287 ;; The following keywords will be bound by CUSTOM.
288 :get :group :initialize :link :load :options :prefix
289 :require :set :tag :type)
290 files (list (locate-library "semi-def")
291 (locate-library "mailcap")
292 (locate-library "mime-def")
293 (locate-library "path-util")
294 (locate-library "poem"))
295 dirs (list (file-name-as-directory (expand-file-name srcdir))))
297 (when (setq file (pop files))
298 (setq dir (file-name-directory file))
299 (unless (member dir dirs)
301 (message "Searching for all the colon keywords in:")
303 (setq dir (pop dirs))
304 (message " %s..." dir)
305 (setq files (directory-files dir t
306 "\\.el\\(\\.gz\\|\\.bz2\\)?$"))
308 (setq file (pop files))
309 (if (string-match "\\(\\.gz$\\)\\|\\.bz2$" file)
310 (let ((temp (expand-file-name "dgnustemp.el" srcdir)))
312 (let* ((binary (if (boundp 'MULE)
315 (coding-system-for-read binary)
316 (coding-system-for-write binary)
317 (input-coding-system binary)
318 (output-coding-system binary)
319 (default-process-coding-system
320 (cons binary binary))
322 (insert-file-contents file nil nil nil t)
326 (if (match-beginning 1)
328 (point-min) (point-max)
329 "gzip" t buffer nil "-cd")
331 (point-min) (point-max)
332 "bzip2" t buffer nil "-d"))
336 (message "In file %s: %s" file code)
338 (write-region (point-min) (point-max) temp
342 (insert-file-contents temp nil nil nil t)
343 (delete-file temp))))
344 (insert-file-contents file nil nil nil t))
345 (while (setq form (condition-case nil
350 (setq elem (car-safe form)
351 form (cdr-safe form))
352 (unless (memq (car-safe elem)
353 '(defcustom defface defgroup
354 define-widget quote))
356 (push (car elem) form)
357 (setq elem (cdr elem)))
361 (eq ?: (aref (symbol-name elem) 0))
362 (not (memq elem ignores))
363 (not (memq elem keywords)))
364 (push elem keywords))))))))
365 (setq keywords (sort keywords
367 (string-lessp (symbol-name a)
370 (insert (format "%s" keywords))
371 (write-region (point-min) (point) cache nil 'silent)
373 "The following colon keywords will be bound at run-time:\n %s"
376 (defconst dgnushack-colon-keywords keywords)
378 (set (car keywords) (car keywords))
379 (setq keywords (cdr keywords)))))
380 (byte-compile 'dgnushack-bind-colon-keywords)
381 (dgnushack-bind-colon-keywords)))
384 (setq :version ':version
385 :set-after ':set-after)
387 (defadvice custom-handle-keyword
388 (around dont-signal-an-error-even-if-unsupported-keyword-is-given
390 "Don't signal an error even if unsupported keyword is given."
391 (if (not (memq (ad-get-arg 1) '(:version :set-after)))
395 (put 'custom-declare-face 'byte-optimizer
396 'byte-optimize-ignore-unsupported-custom-keywords)
397 (put 'custom-declare-group 'byte-optimizer
398 'byte-optimize-ignore-unsupported-custom-keywords)
399 (defun byte-optimize-ignore-unsupported-custom-keywords (form)
400 (if (or (memq ':version (nthcdr 4 form))
401 (memq ':set-after (nthcdr 4 form)))
402 (let ((newform (list (car form) (nth 1 form)
403 (nth 2 form) (nth 3 form)))
404 (args (nthcdr 4 form)))
406 (or (memq (car args) '(:version :set-after))
407 (setq newform (nconc newform (list (car args)
409 (setq args (cdr (cdr args))))
413 (put 'custom-declare-variable 'byte-hunk-handler
414 'byte-compile-file-form-custom-declare-variable)
415 (defun byte-compile-file-form-custom-declare-variable (form)
416 ;; Bind defcustom'ed variables.
417 (if (memq 'free-vars byte-compile-warnings)
418 (setq byte-compile-bound-variables
419 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
420 (if (memq ':version (nthcdr 4 form))
421 ;; Make the variable uncustomizable.
422 `(defvar ,(nth 1 (nth 1 form)) ,(nth 1 (nth 2 form))
423 ,(substring (nth 3 form) (if (string-match "^[\t *]+" (nth 3 form))
426 ;; Ignore unsupported keyword(s).
427 (if (memq ':set-after (nthcdr 4 form))
428 (let ((newform (list (car form) (nth 1 form)
429 (nth 2 form) (nth 3 form)))
430 (args (nthcdr 4 form)))
432 (or (eq (car args) ':set-after)
433 (setq newform (nconc newform (list (car args)
435 (setq args (cdr (cdr args))))
439 (defadvice byte-compile-inline-expand (around ignore-built-in-functions
441 "Ignore built-in functions."
442 (let* ((name (car form))
443 (fn (and (fboundp name)
444 (symbol-function name))))
446 ;; Give up on inlining.
447 (setq ad-return-value form)
450 ;; Unknown variables and functions.
451 (unless (boundp 'buffer-file-coding-system)
452 (defvar buffer-file-coding-system (symbol-value 'file-coding-system)))
453 (unless (featurep 'xemacs)
454 (defalias 'Custom-make-dependencies 'ignore)
455 (defalias 'update-autoloads-from-directory 'ignore))
457 (defalias 'device-sound-enabled-p 'ignore)
458 (defalias 'play-sound-file 'ignore)
459 (defalias 'nndb-request-article 'ignore)
460 (defalias 'efs-re-read-dir 'ignore)
461 (defalias 'ange-ftp-re-read-dir 'ignore)
462 (defalias 'define-mail-user-agent 'ignore)
464 (defconst dgnushack-unexporting-files
465 (append '("dgnushack.el" "dgnuspath.el" "dgnuskwds.el" "lpath.el")
467 (progn (require 'shimbun) nil)
468 (error '("nnshimbun.el")))
469 (unless (or (condition-case code
472 (message "No w3: %s%s, retrying..."
473 (error-message-string code)
474 (if (setq code (locate-library "w3-parse"))
475 (concat " (" code ")")
478 ;; Maybe mis-configured Makefile is used (e.g.
479 ;; configured for FSFmacs but XEmacs is running).
480 (let ((lp (delete dgnushack-w3-directory
481 (copy-sequence load-path))))
482 (if (let ((load-path lp))
486 ;; If success, fix `load-path' for compiling.
489 (message " => fixed; W3DIR=%s"
491 (locate-library "w3-parse")))
493 (message " => ignored")
495 '("nnultimate.el" "webmail.el" "nnwfm.el"))
497 (progn (require 'mh-e) nil)
499 (message "No mh-e: %s%s (ignored)"
500 (error-message-string code)
501 (if (setq code (locate-library "mh-e"))
502 (concat " (" code ")")
506 (progn (require 'xml) nil)
508 (message "No xml: %s%s (ignored)"
509 (error-message-string code)
510 (if (setq code (locate-library "xml"))
511 (concat " (" code ")")
515 (progn (require 'bbdb) nil)
517 (message "No bbdb: %s%s (ignored)"
518 (error-message-string code)
519 (if (setq code (locate-library "bbdb"))
520 (concat " (" code ")")
523 (unless (featurep 'xemacs)
524 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el"))
525 (when (and (not (featurep 'xemacs))
526 (<= emacs-major-version 20))
528 (when (and (fboundp 'base64-decode-string)
529 (subrp (symbol-function 'base64-decode-string)))
531 (when (and (fboundp 'md5) (subrp (symbol-function 'md5)))
533 (unless (boundp 'MULE)
535 "Files which will not be installed.")
537 (defconst dgnushack-exporting-files
538 (let ((files (directory-files srcdir nil "^[^=].*\\.el$" t)))
539 (dolist (file dgnushack-unexporting-files)
540 (setq files (delete file files)))
541 (sort files 'string-lessp))
542 "Files which will be compiled and installed.")
544 (defun dgnushack-exporting-files ()
545 "Print name of files which will be installed."
546 (princ (mapconcat 'identity dgnushack-exporting-files " ")))
548 (defconst dgnushack-dont-compile-files
549 '("mm-bodies.el" "mm-decode.el" "mm-encode.el" "mm-extern.el"
550 "mm-partial.el" "mm-url.el" "mm-uu.el" "mm-view.el" "mml-sec.el"
551 "mml-smime.el" "mml.el" "mml1991.el" "mml2015.el")
552 "Files which should not be byte-compiled.")
554 (defun dgnushack-compile (&optional warn)
555 ;;(setq byte-compile-dynamic t)
557 (setq byte-compile-warnings
558 '(free-vars unresolved callargs redefine)))
559 (unless (locate-library "cus-edit")
560 (error "You do not seem to have Custom installed.
561 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
562 You also then need to add the following to the lisp/dgnushack.el file:
564 (push \"~/lisp/custom\" load-path)
566 Modify to suit your needs."))
569 (message "load-path=(\"%s\")"
570 (mapconcat 'identity load-path "\"\n \""))
572 (dolist (file dgnushack-exporting-files)
573 (setq file (expand-file-name file srcdir))
574 (when (and (file-exists-p
575 (setq elc (concat (file-name-nondirectory file) "c")))
576 (file-newer-than-file-p file elc))
579 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
581 (when (featurep 'xemacs)
582 (setq gnus-xmas-glyph-directory "dummy"))
584 (let ((files dgnushack-exporting-files)
585 ;;(byte-compile-generate-call-tree t)
587 (while (setq file (pop files))
588 (unless (member file dgnushack-dont-compile-files)
589 (setq file (expand-file-name file srcdir))
590 (when (or (not (file-exists-p
591 (setq elc (concat (file-name-nondirectory file) "c"))))
592 (file-newer-than-file-p file elc))
594 (byte-compile-file file)))))))
596 (defun dgnushack-recompile ()
598 (byte-recompile-directory "." 0))
600 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el" srcdir))
601 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el" srcdir))
602 (defvar dgnushack-auto-load-file (expand-file-name "auto-autoloads.el" srcdir))
604 (defun dgnushack-make-cus-load ()
605 (when (condition-case nil
608 (let ((cusload-base-file dgnushack-cus-load-file))
609 (if (fboundp 'custom-make-dependencies)
610 (custom-make-dependencies)
611 (Custom-make-dependencies)))))
613 (defun dgnushack-make-auto-load ()
615 (unless (make-autoload '(define-derived-mode child parent name
618 (defadvice make-autoload (around handle-define-derived-mode activate)
619 "Handle `define-derived-mode'."
620 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
621 (setq ad-return-value
623 (list 'quote (nth 1 (ad-get-arg 0)))
625 (nth 4 (ad-get-arg 0))
628 (put 'define-derived-mode 'doc-string-elt 3))
629 (let ((generated-autoload-file dgnushack-gnus-load-file)
630 (make-backup-files nil)
631 (autoload-package-name "gnus"))
632 (if (featurep 'xemacs)
634 (if (file-exists-p generated-autoload-file)
635 (delete-file generated-autoload-file))
636 (if (file-exists-p dgnushack-auto-load-file)
637 (delete-file dgnushack-auto-load-file)))
638 (with-temp-file generated-autoload-file
640 (if (featurep 'xemacs)
641 (let ((si:message (symbol-function 'message)))
642 (defun message (fmt &rest args)
643 (cond ((and (string-equal "Generating autoloads for %s..." fmt)
644 (file-exists-p (file-name-nondirectory (car args))))
646 fmt (file-name-nondirectory (car args))))
647 ((string-equal "No autoloads found in %s" fmt))
648 ((string-equal "Generating autoloads for %s...done" fmt))
649 (t (apply si:message fmt args))))
651 (batch-update-autoloads)
652 (fset 'message si:message)))
653 (batch-update-autoloads))))
655 (defun dgnushack-make-load ()
656 (message (format "Generating %s..." dgnushack-gnus-load-file))
657 (with-temp-file dgnushack-gnus-load-file
658 (if (file-exists-p dgnushack-cus-load-file)
660 (insert-file-contents dgnushack-cus-load-file)
661 (delete-file dgnushack-cus-load-file)
662 (goto-char (point-min))
663 (search-forward ";;; Code:")
665 (delete-region (point-min) (point))
666 (unless (re-search-forward "\
667 ^[\t ]*(autoload[\t\n ]+\\('\\|(quote[\t\n ]+\\)custom-add-loads[\t\n ]"
669 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))
670 (goto-char (point-min))
672 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
676 (goto-char (point-max))
677 (if (search-backward "custom-versions-load-alist" nil t)
680 (while (eq (char-after) ?\;)
683 (delete-region (point) (point-max))
686 ;;; gnus-load.el --- automatically extracted autoload
690 ;; smiley-* are duplicated. Remove them all.
691 (let ((point (point)))
692 (insert-file-contents dgnushack-gnus-load-file)
694 (while (search-forward "smiley-" nil t)
696 (if (looking-at "(autoload ")
697 (delete-region (point) (progn (forward-sexp) (point)))
700 (goto-char (point-max))
701 (when (search-backward "\n(provide " nil t)
703 (delete-region (point) (point-max)))
706 \(provide 'gnus-load)
709 ;;; version-control: never
710 ;;; no-byte-compile: t
711 ;;; no-update-autoloads: t
713 ;;; gnus-load.el ends here
715 ;; Workaround the bug in some version of XEmacs.
716 (when (featurep 'xemacs)
720 (goto-char (point-min))
721 (when (and (fboundp 'custom-add-loads)
722 (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
723 (search-forward "\n;;; Code:" nil t)
725 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
726 (message (format "Compiling %s..." dgnushack-gnus-load-file))
727 (byte-compile-file dgnushack-gnus-load-file))
730 (defun dgnushack-compose-package ()
731 "Re-split the file gnus-load.el into custom-load.el and
732 auto-autoloads.el. It is silly, should be improved!"
734 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...")
735 (let ((customload (expand-file-name "custom-load.el" srcdir))
736 (autoloads (expand-file-name "auto-autoloads.el" srcdir))
739 (insert-file-contents dgnushack-gnus-load-file)
740 (delete-file dgnushack-gnus-load-file)
741 (when (file-exists-p (concat dgnushack-gnus-load-file "c"))
742 (delete-file (concat dgnushack-gnus-load-file "c")))
744 (looking-at "[\t ;]")
748 ;;; custom-load.el --- automatically extracted custom dependencies\n
750 (goto-char (point-max))
753 (not (looking-at "[\t ]*(custom-add-loads[\t\n ]"))))
756 (insert "\n;;; custom-load.el ends here\n")
757 (write-region start (point) customload)
758 (while (looking-at "[\t ]*$")
761 (if (re-search-forward "^[\t\n ]*(if[\t\n ]+(featurep[\t\n ]" nil t)
762 (let ((from (goto-char (match-beginning 0))))
763 (delete-region from (progn
767 (while (looking-at "[\t ;]")
769 (insert "(if (featurep 'gnus-autoloads) (error \"Already loaded\"))\n")
770 (goto-char (point-max))
773 (not (looking-at "[\t ]*(provide[\t\n ]"))))
774 (insert "(provide 'gnus-autoloads)\n")
775 (write-region start (point) autoloads))
776 (byte-compile-file customload)
777 (byte-compile-file autoloads))
779 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...done
783 (defconst dgnushack-info-file-regexp-en
784 (let ((names '("gnus" "message" "emacs-mime"))
786 (while (setq name (pop names))
787 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
788 (when names "\\|"))))
790 "Regexp matching English info files.")
792 (defconst dgnushack-info-file-regexp-ja
793 (let ((names '("gnus-ja" "message-ja"))
795 (while (setq name (pop names))
796 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
797 (when names "\\|"))))
799 "Regexp matching Japanese info files.")
801 (defun dgnushack-remove-extra-files-in-package ()
802 "Remove extra files in the lisp directory of the XEmacs package."
803 (let ((lisp-dir (expand-file-name (concat "lisp/"
805 (cadr command-line-args-left)
808 (car command-line-args-left))))
809 (when (file-directory-p lisp-dir)
811 (dolist (file dgnushack-exporting-files)
812 (setq files (nconc files (list file (concat file "c")))))
813 (dolist (file (directory-files lisp-dir nil nil t t))
814 (unless (member file files)
815 (setq file (expand-file-name file lisp-dir))
816 (message "Removing %s..." file)
821 (defun dgnushack-install-package-manifest ()
822 "Install MANIFEST file as an XEmacs package."
823 (let* ((package-dir (car command-line-args-left))
824 (product-name (cadr command-line-args-left))
825 (name (expand-file-name (concat "pkginfo/MANIFEST." product-name)
828 (message "Generating %s..." name)
830 (insert "pkginfo/MANIFEST." product-name "\n")
831 (let ((lisp-dir (concat "lisp/" product-name "/"))
832 (files (sort (directory-files "." nil "\\.elc?$" t) 'string-lessp))
834 (while (setq file (pop files))
835 (unless (member file dgnushack-unexporting-files)
836 (insert lisp-dir file "\n")))
838 (sort (directory-files "../texi/" nil
839 (concat dgnushack-info-file-regexp-en
841 dgnushack-info-file-regexp-ja)
844 (while (setq file (pop files))
845 (insert "info/" file "\n"))))))
848 (define-compiler-macro describe-key-briefly (&whole form key &optional insert)
849 (if (condition-case nil
851 (describe-key-briefly '((())) nil)
853 (wrong-number-of-arguments nil);; Old Emacsen.
858 (insert (funcall 'describe-key-briefly ,key))
859 (funcall 'describe-key-briefly ,key))
860 `(funcall 'describe-key-briefly ,key))))
862 ;;; dgnushack.el ends here