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 (pop form))
351 (unless (memq (car-safe elem)
352 '(defcustom defface defgroup
353 define-widget quote))
355 (push (car elem) form)
356 (setq elem (cdr elem)))
360 (eq ?: (aref (symbol-name elem) 0))
361 (not (memq elem ignores))
362 (not (memq elem keywords)))
363 (push elem keywords))))))))
364 (setq keywords (sort keywords
366 (string-lessp (symbol-name a)
369 (insert (format "%s" keywords))
370 (write-region (point-min) (point) cache nil 'silent)
372 "The following colon keywords will be bound at run-time:\n %s"
375 (defconst dgnushack-colon-keywords keywords)
377 (set (car keywords) (car keywords))
378 (setq keywords (cdr keywords)))))
379 (byte-compile 'dgnushack-bind-colon-keywords)
380 (dgnushack-bind-colon-keywords)))
383 (setq :version ':version
384 :set-after ':set-after)
386 (defadvice custom-handle-keyword
387 (around dont-signal-an-error-even-if-unsupported-keyword-is-given
389 "Don't signal an error even if unsupported keyword is given."
390 (if (not (memq (ad-get-arg 1) '(:version :set-after)))
394 (put 'custom-declare-face 'byte-optimizer
395 'byte-optimize-ignore-unsupported-custom-keywords)
396 (put 'custom-declare-group 'byte-optimizer
397 'byte-optimize-ignore-unsupported-custom-keywords)
398 (defun byte-optimize-ignore-unsupported-custom-keywords (form)
399 (if (or (memq ':version (nthcdr 4 form))
400 (memq ':set-after (nthcdr 4 form)))
401 (let ((newform (list (car form) (nth 1 form)
402 (nth 2 form) (nth 3 form)))
403 (args (nthcdr 4 form)))
405 (or (memq (car args) '(:version :set-after))
406 (setq newform (nconc newform (list (car args)
408 (setq args (cdr (cdr args))))
412 (put 'custom-declare-variable 'byte-hunk-handler
413 'byte-compile-file-form-custom-declare-variable)
414 (defun byte-compile-file-form-custom-declare-variable (form)
415 ;; Bind defcustom'ed variables.
416 (if (memq 'free-vars byte-compile-warnings)
417 (setq byte-compile-bound-variables
418 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
419 (if (memq ':version (nthcdr 4 form))
420 ;; Make the variable uncustomizable.
421 `(defvar ,(nth 1 (nth 1 form)) ,(nth 1 (nth 2 form))
422 ,(substring (nth 3 form) (if (string-match "^[\t *]+" (nth 3 form))
425 ;; Ignore unsupported keyword(s).
426 (if (memq ':set-after (nthcdr 4 form))
427 (let ((newform (list (car form) (nth 1 form)
428 (nth 2 form) (nth 3 form)))
429 (args (nthcdr 4 form)))
431 (or (eq (car args) ':set-after)
432 (setq newform (nconc newform (list (car args)
434 (setq args (cdr (cdr args))))
438 (defadvice byte-compile-inline-expand (around ignore-built-in-functions
440 "Ignore built-in functions."
441 (let* ((name (car form))
442 (fn (and (fboundp name)
443 (symbol-function name))))
445 ;; Give up on inlining.
446 (setq ad-return-value form)
449 ;; Unknown variables and functions.
450 (unless (boundp 'buffer-file-coding-system)
451 (defvar buffer-file-coding-system (symbol-value 'file-coding-system)))
452 (unless (featurep 'xemacs)
453 (defalias 'Custom-make-dependencies 'ignore)
454 (defalias 'update-autoloads-from-directory 'ignore))
456 (defalias 'device-sound-enabled-p 'ignore)
457 (defalias 'play-sound-file 'ignore)
458 (defalias 'nndb-request-article 'ignore)
459 (defalias 'efs-re-read-dir 'ignore)
460 (defalias 'ange-ftp-re-read-dir 'ignore)
461 (defalias 'define-mail-user-agent 'ignore)
463 (defconst dgnushack-unexporting-files
464 (append '("dgnushack.el" "dgnuspath.el" "dgnuskwds.el" "lpath.el")
466 (progn (require 'shimbun) nil)
467 (error '("nnshimbun.el")))
468 (unless (or (condition-case code
471 (message "No w3: %s%s, retrying..."
472 (error-message-string code)
473 (if (setq code (locate-library "w3-parse"))
474 (concat " (" code ")")
477 ;; Maybe mis-configured Makefile is used (e.g.
478 ;; configured for FSFmacs but XEmacs is running).
479 (let ((lp (delete dgnushack-w3-directory
480 (copy-sequence load-path))))
481 (if (let ((load-path lp))
485 ;; If success, fix `load-path' for compiling.
488 (message " => fixed; W3DIR=%s"
490 (locate-library "w3-parse")))
492 (message " => ignored")
494 '("nnultimate.el" "webmail.el" "nnwfm.el"))
496 (progn (require 'mh-e) nil)
498 (message "No mh-e: %s%s (ignored)"
499 (error-message-string code)
500 (if (setq code (locate-library "mh-e"))
501 (concat " (" code ")")
505 (progn (require 'xml) nil)
507 (message "No xml: %s%s (ignored)"
508 (error-message-string code)
509 (if (setq code (locate-library "xml"))
510 (concat " (" code ")")
514 (progn (require 'bbdb) nil)
516 (message "No bbdb: %s%s (ignored)"
517 (error-message-string code)
518 (if (setq code (locate-library "bbdb"))
519 (concat " (" code ")")
522 (unless (featurep 'xemacs)
523 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el"))
524 (when (and (not (featurep 'xemacs))
525 (<= emacs-major-version 20))
527 (when (and (fboundp 'base64-decode-string)
528 (subrp (symbol-function 'base64-decode-string)))
530 (when (and (fboundp 'md5) (subrp (symbol-function 'md5)))
532 (unless (boundp 'MULE)
534 "Files which will not be installed.")
536 (defconst dgnushack-exporting-files
537 (let ((files (directory-files srcdir nil "^[^=].*\\.el$" t)))
538 (dolist (file dgnushack-unexporting-files)
539 (setq files (delete file files)))
540 (sort files 'string-lessp))
541 "Files which will be compiled and installed.")
543 (defun dgnushack-exporting-files ()
544 "Print name of files which will be installed."
545 (princ (mapconcat 'identity dgnushack-exporting-files " ")))
547 (defun dgnushack-compile (&optional warn)
548 ;;(setq byte-compile-dynamic t)
550 (setq byte-compile-warnings
551 '(free-vars unresolved callargs redefine)))
552 (unless (locate-library "cus-edit")
553 (error "You do not seem to have Custom installed.
554 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
555 You also then need to add the following to the lisp/dgnushack.el file:
557 (push \"~/lisp/custom\" load-path)
559 Modify to suit your needs."))
562 (message "load-path=(\"%s\")"
563 (mapconcat 'identity load-path "\"\n \""))
565 (dolist (file dgnushack-exporting-files)
566 (setq file (expand-file-name file srcdir))
567 (when (and (file-exists-p
568 (setq elc (concat (file-name-nondirectory file) "c")))
569 (file-newer-than-file-p file elc))
572 (let ((files dgnushack-exporting-files)
573 ;;(byte-compile-generate-call-tree t)
575 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
577 (when (featurep 'xemacs)
578 (setq gnus-xmas-glyph-directory "dummy"))
579 (while (setq file (pop files))
580 (setq file (expand-file-name file srcdir))
581 (when (or (not (file-exists-p
582 (setq elc (concat (file-name-nondirectory file) "c"))))
583 (file-newer-than-file-p file elc))
585 (byte-compile-file file))))))
587 (defun dgnushack-recompile ()
589 (byte-recompile-directory "." 0))
591 (defvar dgnushack-gnus-load-file (expand-file-name "gnus-load.el" srcdir))
592 (defvar dgnushack-cus-load-file (expand-file-name "cus-load.el" srcdir))
593 (defvar dgnushack-auto-load-file (expand-file-name "auto-autoloads.el" srcdir))
595 (defun dgnushack-make-cus-load ()
596 (when (condition-case nil
599 (let ((cusload-base-file dgnushack-cus-load-file))
600 (if (fboundp 'custom-make-dependencies)
601 (custom-make-dependencies)
602 (Custom-make-dependencies)))))
604 (defun dgnushack-make-auto-load ()
606 (unless (make-autoload '(define-derived-mode child parent name
609 (defadvice make-autoload (around handle-define-derived-mode activate)
610 "Handle `define-derived-mode'."
611 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
612 (setq ad-return-value
614 (list 'quote (nth 1 (ad-get-arg 0)))
616 (nth 4 (ad-get-arg 0))
619 (put 'define-derived-mode 'doc-string-elt 3))
620 (let ((generated-autoload-file dgnushack-gnus-load-file)
621 (make-backup-files nil)
622 (autoload-package-name "gnus"))
623 (if (featurep 'xemacs)
625 (if (file-exists-p generated-autoload-file)
626 (delete-file generated-autoload-file))
627 (if (file-exists-p dgnushack-auto-load-file)
628 (delete-file dgnushack-auto-load-file)))
629 (with-temp-file generated-autoload-file
631 (if (featurep 'xemacs)
632 (let ((si:message (symbol-function 'message)))
633 (defun message (fmt &rest args)
634 (cond ((and (string-equal "Generating autoloads for %s..." fmt)
635 (file-exists-p (file-name-nondirectory (car args))))
637 fmt (file-name-nondirectory (car args))))
638 ((string-equal "No autoloads found in %s" fmt))
639 ((string-equal "Generating autoloads for %s...done" fmt))
640 (t (apply si:message fmt args))))
642 (batch-update-autoloads)
643 (fset 'message si:message)))
644 (batch-update-autoloads))))
646 (defun dgnushack-make-load ()
647 (message (format "Generating %s..." dgnushack-gnus-load-file))
648 (with-temp-file dgnushack-gnus-load-file
649 (if (file-exists-p dgnushack-cus-load-file)
651 (insert-file-contents dgnushack-cus-load-file)
652 (delete-file dgnushack-cus-load-file)
653 (goto-char (point-min))
654 (search-forward ";;; Code:")
656 (delete-region (point-min) (point))
657 (unless (re-search-forward "\
658 ^[\t ]*(autoload[\t\n ]+\\('\\|(quote[\t\n ]+\\)custom-add-loads[\t\n ]"
660 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))
661 (goto-char (point-min))
663 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
667 (goto-char (point-max))
668 (if (search-backward "custom-versions-load-alist" nil t)
671 (while (eq (char-after) ?\;)
674 (delete-region (point) (point-max))
677 ;;; gnus-load.el --- automatically extracted autoload
681 ;; smiley-* are duplicated. Remove them all.
682 (let ((point (point)))
683 (insert-file-contents dgnushack-gnus-load-file)
685 (while (search-forward "smiley-" nil t)
687 (if (looking-at "(autoload ")
688 (delete-region (point) (progn (forward-sexp) (point)))
691 (goto-char (point-max))
692 (when (search-backward "\n(provide " nil t)
694 (delete-region (point) (point-max)))
697 \(provide 'gnus-load)
700 ;;; version-control: never
701 ;;; no-byte-compile: t
702 ;;; no-update-autoloads: t
704 ;;; gnus-load.el ends here
706 ;; Workaround the bug in some version of XEmacs.
707 (when (featurep 'xemacs)
711 (goto-char (point-min))
712 (when (and (fboundp 'custom-add-loads)
713 (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
714 (search-forward "\n;;; Code:" nil t)
716 (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
717 (message (format "Compiling %s..." dgnushack-gnus-load-file))
718 (byte-compile-file dgnushack-gnus-load-file))
721 (defun dgnushack-compose-package ()
722 "Re-split the file gnus-load.el into custom-load.el and
723 auto-autoloads.el. It is silly, should be improved!"
725 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...")
726 (let ((customload (expand-file-name "custom-load.el" srcdir))
727 (autoloads (expand-file-name "auto-autoloads.el" srcdir))
730 (insert-file-contents dgnushack-gnus-load-file)
731 (delete-file dgnushack-gnus-load-file)
732 (when (file-exists-p (concat dgnushack-gnus-load-file "c"))
733 (delete-file (concat dgnushack-gnus-load-file "c")))
735 (looking-at "[\t ;]")
739 ;;; custom-load.el --- automatically extracted custom dependencies\n
741 (goto-char (point-max))
744 (not (looking-at "[\t ]*(custom-add-loads[\t\n ]"))))
747 (insert "\n;;; custom-load.el ends here\n")
748 (write-region start (point) customload)
749 (while (looking-at "[\t ]*$")
752 (if (re-search-forward "^[\t\n ]*(if[\t\n ]+(featurep[\t\n ]" nil t)
753 (let ((from (goto-char (match-beginning 0))))
754 (delete-region from (progn
758 (while (looking-at "[\t ;]")
760 (insert "(if (featurep 'gnus-autoloads) (error \"Already loaded\"))\n")
761 (goto-char (point-max))
764 (not (looking-at "[\t ]*(provide[\t\n ]"))))
765 (insert "(provide 'gnus-autoloads)\n")
766 (write-region start (point) autoloads))
767 (byte-compile-file customload)
768 (byte-compile-file autoloads))
770 Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...done
774 (defconst dgnushack-info-file-regexp-en
775 (let ((names '("gnus" "message" "emacs-mime"))
777 (while (setq name (pop names))
778 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
779 (when names "\\|"))))
781 "Regexp matching English info files.")
783 (defconst dgnushack-info-file-regexp-ja
784 (let ((names '("gnus-ja" "message-ja"))
786 (while (setq name (pop names))
787 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
788 (when names "\\|"))))
790 "Regexp matching Japanese info files.")
792 (defun dgnushack-remove-extra-files-in-package ()
793 "Remove extra files in the lisp directory of the XEmacs package."
794 (let ((lisp-dir (expand-file-name (concat "lisp/"
796 (cadr command-line-args-left)
799 (car command-line-args-left))))
800 (when (file-directory-p lisp-dir)
802 (dolist (file dgnushack-exporting-files)
803 (setq files (nconc files (list file (concat file "c")))))
804 (dolist (file (directory-files lisp-dir nil nil t t))
805 (unless (member file files)
806 (setq file (expand-file-name file lisp-dir))
807 (message "Removing %s..." file)
812 (defun dgnushack-install-package-manifest ()
813 "Install MANIFEST file as an XEmacs package."
814 (let* ((package-dir (car command-line-args-left))
815 (product-name (cadr command-line-args-left))
816 (name (expand-file-name (concat "pkginfo/MANIFEST." product-name)
819 (message "Generating %s..." name)
821 (insert "pkginfo/MANIFEST." product-name "\n")
822 (let ((lisp-dir (concat "lisp/" product-name "/"))
823 (files (sort (directory-files "." nil "\\.elc?$" t) 'string-lessp))
825 (while (setq file (pop files))
826 (unless (member file dgnushack-unexporting-files)
827 (insert lisp-dir file "\n")))
829 (sort (directory-files "../texi/" nil
830 (concat dgnushack-info-file-regexp-en
832 dgnushack-info-file-regexp-ja)
835 (while (setq file (pop files))
836 (insert "info/" file "\n"))))))
839 (define-compiler-macro describe-key-briefly (&whole form key &optional insert)
840 (if (condition-case nil
842 (describe-key-briefly '((())) nil)
844 (wrong-number-of-arguments nil);; Old Emacsen.
849 (insert (funcall 'describe-key-briefly ,key))
850 (funcall 'describe-key-briefly ,key))
851 `(funcall 'describe-key-briefly ,key))))
853 ;;; dgnushack.el ends here