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,
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: news, path
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
32 ;; Set coding priority of Shift-JIS to the bottom.
33 (if (featurep 'xemacs)
34 (defalias 'set-coding-priority 'ignore)
35 (defalias 'coding-priority-list 'ignore)
36 (defalias 'set-coding-priority-list 'ignore))
37 (cond ((and (featurep 'xemacs) (featurep 'mule))
38 (if (memq 'shift-jis (coding-priority-list))
39 (set-coding-priority-list
40 (append (delq 'shift-jis (coding-priority-list)) '(shift-jis)))))
42 (if (memq 'coding-category-sjis coding-category-list)
44 (append (delq 'coding-category-sjis
45 (copy-sequence coding-category-list))
46 '(coding-category-sjis))))))
48 (defvar dgnushack-default-load-path (copy-sequence load-path))
50 (defalias 'facep 'ignore)
55 ;; `dolist' might not be available because of ``-no-autoloads''.
57 ;; It may have been defined in egg.el.
59 (load "cl-macs" nil t))
61 (defvar srcdir (or (getenv "srcdir") "."))
62 (defvar loaddir (and load-file-name (file-name-directory load-file-name)))
64 (defvar dgnushack-w3-directory (let ((w3dir (getenv "W3DIR")))
65 (unless (zerop (length w3dir))
66 (file-name-as-directory w3dir))))
68 (let ((urldir (getenv "URLDIR")))
69 (unless (zerop (length urldir))
70 (setq urldir (file-name-as-directory urldir))
71 (push (file-name-as-directory urldir) load-path))
72 (when (and dgnushack-w3-directory
73 (not (string-equal urldir dgnushack-w3-directory)))
74 (push dgnushack-w3-directory load-path)))
76 ;; If we are building w3 in a different directory than the source
77 ;; directory, we must read *.el from source directory and write *.elc
78 ;; into the building directory. For that, we define this function
79 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
80 (defun byte-compile-dest-file (filename)
81 "Convert an Emacs Lisp source file name to a compiled file name.
82 In addition, remove directory name part from FILENAME."
83 (setq filename (byte-compiler-base-file-name filename))
84 (setq filename (file-name-sans-versions filename))
85 (setq filename (file-name-nondirectory filename))
86 (if (memq system-type '(win32 w32 mswindows windows-nt))
87 (setq filename (downcase filename)))
88 (cond ((eq system-type 'vax-vms)
89 (concat (substring filename 0 (string-match ";" filename)) "c"))
90 ((string-match emacs-lisp-file-regexp filename)
91 (concat (substring filename 0 (match-beginning 0)) ".elc"))
92 (t (concat filename ".elc"))))
95 ;; To avoid having defsubsts and inlines happen.
96 ;(if (featurep 'xemacs)
97 ; (require 'byte-optimize)
98 ; (require 'byte-opt))
99 ;(defun byte-optimize-inline-handler (form)
100 ; "byte-optimize-handler for the `inline' special-form."
101 ; (cons 'progn (cdr form)))
102 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
104 (when (and (not (featurep 'xemacs))
105 (= emacs-major-version 21)
106 (>= emacs-minor-version 3)
108 (let ((byte-compile-error-on-warn t))
109 (byte-optimize-form (quote (pop x)) t)
111 (error (string-match "called for effect"
112 (error-message-string code)))))
113 (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
116 "Silence the warning \"...called for effect\" for the `pop' form.
117 It is effective only when the `pop' macro is defined by cl.el rather
120 (if (and (eq (car-safe form) 'car)
122 (setq tmp (get 'car 'side-effect-free))
123 (not byte-compile-delete-errors)
124 (not (eq tmp 'error-free))
125 (eq (car-safe (cadr form)) 'prog1)
126 (let ((var (cadr (cadr form)))
127 (last (nth 2 (cadr form))))
129 (null (nthcdr 3 (cadr form)))
130 (eq (car-safe last) 'setq)
132 (eq (car-safe (nth 2 last)) 'cdr)
133 (eq (cadr (nth 2 last)) var))))
135 (put 'car 'side-effect-free 'error-free)
138 (put 'car 'side-effect-free tmp)))
141 (when (and (not (featurep 'xemacs))
142 (byte-optimize-form '(and (> 0 1) foo) t))
143 (defadvice byte-optimize-form-code-walker
144 (around fix-bug-in-and/or-forms (form for-effect) activate)
145 "Optimize the rest of the and/or forms.
146 It has been fixed in XEmacs before releasing 21.4 and also has been
147 fixed in Emacs after 21.3."
148 (if (and for-effect (memq (car-safe form) '(and or)))
149 (let ((fn (car form))
150 (backwards (reverse (cdr form))))
151 (while (and backwards
152 (null (setcar backwards
153 (byte-optimize-form (car backwards) t))))
154 (setq backwards (cdr backwards)))
155 (if (and (cdr form) (null backwards))
157 " all subforms of %s called for effect; deleted" form))
160 (mapcar 'byte-optimize-form (cdr backwards))))
161 (setq ad-return-value (cons fn (nreverse backwards))))
164 ;; Add `configure-package-path' to `load-path' for XEmacs. Those paths
165 ;; won't appear in `load-path' when XEmacs starts with the `-no-autoloads'
166 ;; option or the `-vanilla' option because of a bug. :<
167 (when (and (featurep 'xemacs)
168 (boundp 'configure-package-path)
169 (listp configure-package-path))
174 (when (and (stringp path)
175 (not (string-equal path ""))
177 (setq path (expand-file-name "lisp" path))))
178 (directory-files path t)))
179 configure-package-path)))
182 (setq path (car paths)
185 (not (or (string-match "/\\.\\.?\\'" path)
186 (member (file-name-as-directory path) load-path)
187 (member path load-path)))
188 (file-directory-p path))
189 (push (file-name-as-directory path) adds)))
190 (setq load-path (nconc (nreverse adds) load-path))))
192 (if (file-exists-p (expand-file-name "dgnuspath.el" srcdir))
193 (load (expand-file-name "dgnuspath.el" srcdir) nil nil t))
196 (load "~/.lpath.el" t nil t)
197 (error (message "Error in \"~/.lpath.el\" file: %s" err)))
199 (when (featurep 'xemacs)
201 (require 'timer-funcs)
203 You should upgrade your XEmacs packages, especially xemacs-base.\n"))
205 ;; The reason that to load `advice' is necessary is:
206 ;; 1. `path-util' loads poe.elc.
207 ;; 2. poe.elc requires the `ad-add-advice' function which is expanded
209 ;; 3. XEmacs is running with the -no-autoloads option.
212 ;; Don't load path-util until `char-after' and `char-before' have been
213 ;; optimized because it requires `poe' and then modify the functions.
217 APEL was not found or an error occurred. You will need to run the
218 configure script again adding the --with-addpath=APEL_PATH option.\n"
221 (unless (locate-library "mel")
223 (unless (module-installed-p 'mel)
224 ;; FLIM 1.14 may have installed in two "flim" subdirectories.
225 (push (expand-file-name "flim"
226 (file-name-directory (get-latest-path "^apel$" t)))
228 (unless (module-installed-p 'mel)
230 FLIM was not found. You will need to run the configure script again
231 adding the --with-addpath=FLIM_PATH option.\n"
235 ;; Work around for an incompatibility (XEmacs 21.4 vs. 21.5), see the
236 ;; following threads:
238 ;; http://thread.gmane.org/gmane.emacs.gnus.general/56414
239 ;; Subject: attachment problems found but not fixed
241 ;; http://thread.gmane.org/gmane.emacs.gnus.general/56459
242 ;; Subject: Splitting mail -- XEmacs 21.4 vs 21.5
244 ;; http://thread.gmane.org/gmane.emacs.xemacs.beta/20519
245 ;; Subject: XEmacs 21.5 and Gnus fancy splitting.
246 (when (and (featurep 'xemacs)
247 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
248 (modify-syntax-entry ?= " " table)
250 (with-syntax-table table
252 (goto-char (point-min))
255 ;; The original `with-syntax-table' uses `copy-syntax-table' which
256 ;; doesn't seem to copy modified syntax entries in XEmacs 21.5.
257 (defmacro with-syntax-table (syntab &rest body)
258 "Evaluate BODY with the SYNTAB as the current syntax table."
259 `(let ((stab (syntax-table)))
262 ;;(set-syntax-table (copy-syntax-table ,syntab))
263 (set-syntax-table ,syntab)
265 (set-syntax-table stab)))))
267 (push srcdir load-path)
268 (push loaddir load-path)
269 (load (expand-file-name "lpath.el" loaddir) nil t)
273 ;; Bind functions defined by `defun-maybe'.
274 (put 'defun-maybe 'byte-hunk-handler 'byte-compile-file-form-defun-maybe)
275 (defun byte-compile-file-form-defun-maybe (form)
276 (if (and (not (fboundp (nth 1 form)))
277 (memq 'unresolved byte-compile-warnings))
278 (setq byte-compile-function-environment
279 (cons (cons (nth 1 form)
280 (cons 'lambda (cdr (cdr form))))
281 byte-compile-function-environment)))
284 ;; Unknown variables and functions.
285 (unless (featurep 'xemacs)
286 (defalias 'Custom-make-dependencies 'ignore)
287 (defalias 'update-autoloads-from-directory 'ignore))
289 (defalias 'device-sound-enabled-p 'ignore)
290 (defalias 'play-sound-file 'ignore)
291 (defalias 'nndb-request-article 'ignore)
292 (defalias 'efs-re-read-dir 'ignore)
293 (defalias 'ange-ftp-re-read-dir 'ignore)
294 (defalias 'define-mail-user-agent 'ignore)
297 (when (featurep 'xemacs)
298 (unless (fboundp 'defadvice)
299 (autoload 'defadvice "advice" nil nil 'macro))
300 (autoload 'Info-directory "info" nil t)
301 (autoload 'Info-menu "info" nil t)
302 (autoload 'annotations-at "annotations")
303 (autoload 'apropos "apropos" nil t)
304 (autoload 'apropos-command "apropos" nil t)
305 (autoload 'bbdb-complete-name "bbdb-com" nil t)
306 (autoload 'browse-url "browse-url" nil t)
307 (autoload 'c-mode "cc-mode" nil t)
308 (autoload 'customize-apropos "cus-edit" nil t)
309 (autoload 'customize-save-variable "cus-edit" nil t)
310 (autoload 'customize-set-variable "cus-edit" nil t)
311 (autoload 'customize-variable "cus-edit" nil t)
312 (autoload 'delete-annotation "annotations")
313 (autoload 'dolist "cl-macs" nil nil 'macro)
314 (autoload 'enriched-decode "enriched")
315 (autoload 'executable-find "executable")
316 (autoload 'font-lock-fontify-buffer "font-lock" nil t)
317 (autoload 'info "info" nil t)
318 (autoload 'mail-extract-address-components "mail-extr")
319 (autoload 'mail-fetch-field "mail-utils")
320 (autoload 'make-annotation "annotations")
321 (autoload 'make-display-table "disp-table")
323 (autoload 'ps-despool "ps-print" nil t)
324 (autoload 'ps-spool-buffer "ps-print" nil t)
325 (autoload 'ps-spool-buffer-with-faces "ps-print" nil t)
326 (autoload 'read-passwd "passwd")
327 (autoload 'regexp-opt "regexp-opt")
328 (autoload 'reporter-submit-bug-report "reporter")
329 (if (and (emacs-version>= 21 5)
330 (not (featurep 'sxemacs)))
331 (autoload 'setenv "process" nil t)
332 (autoload 'setenv "env" nil t))
333 (autoload 'sgml-mode "psgml" nil t)
334 (autoload 'sha1 "sha1")
335 (autoload 'sha1-binary "sha1")
336 (autoload 'smtpmail-send-it "smtpmail")
337 (autoload 'sort-numeric-fields "sort" nil t)
338 (autoload 'sort-subr "sort")
339 (autoload 'trace-function-background "trace" nil t)
340 (autoload 'w3-do-setup "w3")
341 (autoload 'w3-prepare-buffer "w3-display")
342 (autoload 'w3-region "w3-display" nil t)
343 (defalias 'frame-char-height 'frame-height)
344 (defalias 'frame-char-width 'frame-width)
345 (defalias 'frame-parameter 'frame-property)
346 (defalias 'make-overlay 'ignore)
347 (defalias 'overlay-end 'ignore)
348 (defalias 'overlay-get 'ignore)
349 (defalias 'overlay-put 'ignore)
350 (defalias 'overlay-start 'ignore)
351 (defalias 'overlays-in 'ignore)
352 (defalias 'replace-dehighlight 'ignore)
353 (defalias 'replace-highlight 'ignore)
354 (defalias 'w3-coding-system-for-mime-charset 'ignore)))
358 (when (featurep 'xemacs)
359 (autoload 'c-mode "cc-mode" nil t)
360 (autoload 'font-lock-mode "font-lock" nil t)
361 (autoload 'read-kbd-macro "edmacro" nil t)
362 (autoload 'turn-on-font-lock "font-lock" nil t))
363 (autoload 'nnheader-detect-coding-region "nnheader")
364 (autoload 'std11-extract-addresses-components "nnheader")
365 (autoload 'std11-fold-region "nnheader")
366 (autoload 'std11-narrow-to-field "nnheader")
367 (autoload 'std11-unfold-region "nnheader"))
369 (defconst dgnushack-unexporting-files
370 (append '("dgnushack.el" "dgnuspath.el" "dgnuskwds.el" "lpath.el"
371 "legacy-gnus-agent.el")
372 (unless (or (condition-case code
375 (message "No w3: %s%s, retrying..."
376 (error-message-string code)
377 (if (setq code (locate-library "w3-parse"))
378 (concat " (" code ")")
381 ;; Maybe mis-configured Makefile is used (e.g.
382 ;; configured for FSFmacs but XEmacs is running).
383 (let ((lp (delete dgnushack-w3-directory
384 (copy-sequence load-path))))
385 (if (let ((load-path lp))
389 ;; If success, fix `load-path' for compiling.
392 (message " => fixed; W3DIR=%s"
394 (locate-library "w3-parse")))
396 (message " => ignored")
398 '("nnultimate.el" "webmail.el" "nnwfm.el"))
400 (progn (require 'mh-e) nil)
402 (message "No mh-e: %s%s (ignored)"
403 (error-message-string code)
404 (if (setq code (locate-library "mh-e"))
405 (concat " (" code ")")
409 (progn (require 'xml) nil)
411 (message "No xml: %s%s (ignored)"
412 (error-message-string code)
413 (if (setq code (locate-library "xml"))
414 (concat " (" code ")")
418 (progn (require 'bbdb) nil)
420 (message "No bbdb: %s%s (ignored)"
421 (error-message-string code)
422 (if (setq code (locate-library "bbdb"))
423 (concat " (" code ")")
426 (unless (featurep 'xemacs)
427 '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el"))
428 (when (and (fboundp 'base64-decode-string)
429 (subrp (symbol-function 'base64-decode-string)))
431 (when (and (fboundp 'md5) (subrp (symbol-function 'md5)))
433 (when (featurep 'xemacs)
435 "Files which will not be installed.")
437 (defconst dgnushack-exporting-files
438 (let ((files (directory-files srcdir nil "^[^=].*\\.el$" t)))
439 (dolist (file dgnushack-unexporting-files)
440 (setq files (delete file files)))
441 (sort files 'string-lessp))
442 "Files which will be compiled and installed.")
444 (defun dgnushack-exporting-files ()
445 "Print name of files which will be installed."
446 (princ (mapconcat 'identity dgnushack-exporting-files " ")))
448 (defconst dgnushack-dont-compile-files
450 "mm-bodies.el" "mm-decode.el" "mm-encode.el" "mm-extern.el"
451 "mm-partial.el" "mm-uu.el" "mm-view.el" "mml-sec.el" "mml-smime.el"
452 "mml.el" "mml1991.el" "mml2015.el")
453 "Files which should not be byte-compiled.")
455 (defun dgnushack-compile-verbosely ()
456 "Call dgnushack-compile with warnings ENABLED. If you are compiling
457 patches to gnus, you should consider modifying make.bat to call
458 dgnushack-compile-verbosely. All other users should continue to use
460 (dgnushack-compile t))
462 (defun dgnushack-compile (&optional warn)
463 ;;(setq byte-compile-dynamic t)
465 (setq byte-compile-warnings
466 '(free-vars unresolved callargs redefine)))
469 (message "load-path=(\"%s\")"
470 (mapconcat 'identity load-path "\"\n \""))
472 (dolist (file dgnushack-exporting-files)
473 (setq file (expand-file-name file srcdir))
474 (when (and (file-exists-p
475 (setq elc (concat (file-name-nondirectory file) "c")))
476 (file-newer-than-file-p file elc))
479 ;; Avoid barfing (from gnus-xmas) because the etc directory is not yet
481 (when (featurep 'xemacs)
482 (setq gnus-xmas-glyph-directory "dummy"))
484 (let ((files dgnushack-exporting-files)
485 ;;(byte-compile-generate-call-tree t)
487 (while (setq file (pop files))
488 (unless (member file dgnushack-dont-compile-files)
489 (setq file (expand-file-name file srcdir))
490 (when (or (not (file-exists-p
491 (setq elc (concat (file-name-nondirectory file) "c"))))
492 (file-newer-than-file-p file elc))
494 (byte-compile-file file)))))))
496 (defun dgnushack-recompile ()
498 (byte-recompile-directory "." 0))
500 (defvar dgnushack-gnus-load-file
501 (if (featurep 'xemacs)
502 (expand-file-name "auto-autoloads.el" srcdir)
503 (expand-file-name "gnus-load.el" srcdir)))
505 (defvar dgnushack-cus-load-file
506 (if (featurep 'xemacs)
507 (expand-file-name "custom-load.el" srcdir)
508 (expand-file-name "cus-load.el" srcdir)))
510 (defun dgnushack-make-cus-load ()
512 (let ((cusload-base-file dgnushack-cus-load-file))
513 (if (fboundp 'custom-make-dependencies)
514 (custom-make-dependencies)
515 (Custom-make-dependencies))
516 (when (featurep 'xemacs)
517 (message "Compiling %s..." dgnushack-cus-load-file)
518 (byte-compile-file dgnushack-cus-load-file))))
520 (defun dgnushack-make-auto-load ()
522 (unless (make-autoload '(define-derived-mode child parent name
525 (defadvice make-autoload (around handle-define-derived-mode activate)
526 "Handle `define-derived-mode'."
527 (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
528 (setq ad-return-value
530 (list 'quote (nth 1 (ad-get-arg 0)))
532 (nth 4 (ad-get-arg 0))
535 (put 'define-derived-mode 'doc-string-elt 3))
536 (let ((generated-autoload-file dgnushack-gnus-load-file)
537 (make-backup-files nil)
538 (autoload-package-name "gnus"))
539 (if (featurep 'xemacs)
540 (if (file-exists-p generated-autoload-file)
541 (delete-file generated-autoload-file))
542 (with-temp-file generated-autoload-file
544 (if (featurep 'xemacs)
545 (let ((si:message (symbol-function 'message)))
546 (defun message (fmt &rest args)
547 (cond ((and (string-equal "Generating autoloads for %s..." fmt)
548 (file-exists-p (file-name-nondirectory (car args))))
550 fmt (file-name-nondirectory (car args))))
551 ((string-equal "No autoloads found in %s" fmt))
552 ((string-equal "Generating autoloads for %s...done" fmt))
553 (t (apply si:message fmt args))))
555 (batch-update-autoloads)
556 (fset 'message si:message)))
557 (batch-update-autoloads))))
559 (defun dgnushack-make-load ()
560 (unless (featurep 'xemacs)
561 (message "Generating %s..." dgnushack-gnus-load-file)
562 (with-temp-file dgnushack-gnus-load-file
563 (insert-file-contents dgnushack-cus-load-file)
564 (delete-file dgnushack-cus-load-file)
565 (goto-char (point-min))
566 (search-forward ";;; Code:")
568 (delete-region (point-min) (point))
570 ;;; gnus-load.el --- automatically extracted custom dependencies and autoload
574 (goto-char (point-max))
575 (if (search-backward "custom-versions-load-alist" nil t)
578 (while (eq (char-after) ?\;)
581 (delete-region (point) (point-max))
583 ;; smiley-* are duplicated. Remove them all.
584 (let ((point (point)))
585 (insert-file-contents dgnushack-gnus-load-file)
587 (while (search-forward "smiley-" nil t)
589 (if (looking-at "(autoload ")
590 (delete-region (point) (progn (forward-sexp) (point)))
593 (goto-char (point-max))
594 (when (search-backward "\n(provide " nil t)
596 (delete-region (point) (point-max)))
599 \(provide 'gnus-load)
602 ;;; version-control: never
603 ;;; no-byte-compile: t
604 ;;; no-update-autoloads: t
606 ;;; gnus-load.el ends here
609 (message "Compiling %s..." dgnushack-gnus-load-file)
610 (byte-compile-file dgnushack-gnus-load-file)
611 (when (featurep 'xemacs)
612 (message "Creating dummy gnus-load.el...")
613 (with-temp-file (expand-file-name "gnus-load.el")
616 \(provide 'gnus-load)
619 ;;; version-control: never
620 ;;; no-byte-compile: t
621 ;;; no-update-autoloads: t
623 ;;; gnus-load.el ends here"))))
626 (defconst dgnushack-info-file-regexp-en
627 (let ((names '("gnus" "message" "emacs-mime"))
629 (while (setq name (pop names))
630 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
631 (when names "\\|"))))
633 "Regexp matching English info files.")
635 (defconst dgnushack-info-file-regexp-ja
636 (let ((names '("gnus-ja" "message-ja"))
638 (while (setq name (pop names))
639 (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
640 (when names "\\|"))))
642 "Regexp matching Japanese info files.")
644 (defun dgnushack-remove-extra-files-in-package ()
645 "Remove extra files in the lisp directory of the XEmacs package."
646 (let ((lisp-dir (expand-file-name (concat "lisp/"
648 (cadr command-line-args-left)
651 (car command-line-args-left))))
652 (setq command-line-args-left nil)
653 (when (file-directory-p lisp-dir)
655 (dolist (file dgnushack-exporting-files)
656 (setq files (nconc files (list file (concat file "c")))))
657 (dolist (file (directory-files lisp-dir nil nil t t))
658 (unless (member file files)
659 (setq file (expand-file-name file lisp-dir))
660 (message "Removing %s..." file)
665 (defun dgnushack-install-package-manifest ()
666 "Install MANIFEST file as an XEmacs package."
667 (let* ((package-dir (pop command-line-args-left))
668 (product-name (pop command-line-args-left))
669 (pkginfo-dir (expand-file-name "pkginfo" package-dir))
670 (name (expand-file-name (concat "MANIFEST." product-name)
673 (unless (file-directory-p pkginfo-dir)
674 (message "Creating directory %s/..." pkginfo-dir)
675 (make-directory pkginfo-dir))
676 (message "Generating %s..." name)
678 (insert "pkginfo/MANIFEST." product-name "\n")
679 (let ((lisp-dir (concat "lisp/" product-name "/"))
680 (files (sort (directory-files "." nil "\\.elc?$" t) 'string-lessp))
682 (while (setq file (pop files))
683 (unless (member file dgnushack-unexporting-files)
684 (insert lisp-dir file "\n")))
686 (sort (directory-files "../texi/" nil
687 (concat dgnushack-info-file-regexp-en
689 dgnushack-info-file-regexp-ja)
692 (while (setq file (pop files))
693 (insert "info/" file "\n"))
694 (insert "etc/gnus-tut.txt\n")
696 (sort (directory-files "../etc/images/gnus/" nil
697 "\\.\\(pbm\\|xbm\\|xpm\\)\\'"
700 (while (setq file (pop files))
701 (insert "etc/images/gnus/" file "\n"))
702 (insert "etc/images/gnus/x-splash\n")
704 (sort (directory-files "../etc/images/smilies/" nil
705 "\\.\\(pbm\\|xpm\\)\\'"
708 (while (setq file (pop files))
709 (insert "etc/images/smilies/" file "\n"))))))
711 (defun dgnushack-find-lisp-shadows (&optional lispdir)
712 "Return a list of directories in which other Gnus installations exist.
713 This function looks for the other Gnus installations which will shadow
714 the new Gnus Lisp modules which have been installed in LISPDIR, using
715 the default `load-path'. The return value will make sense only when
716 LISPDIR is existent and is listed in the default `load-path'. Assume
717 LISPDIR will be prepended to `load-path' by a user if the default
718 `load-path' does not contain it."
720 (setq lispdir (getenv "lispdir")))
721 (when (and lispdir (file-directory-p lispdir))
722 (setq lispdir (file-truename (directory-file-name lispdir)))
723 (let ((indices '("gnus.elc" "gnus.el" "gnus.el.bz2" "gnus.el.gz"
724 "message.elc" "message.el" "message.el.bz2"
726 (path (delq nil (mapcar
729 (when (and p (file-directory-p p))
730 (file-truename (directory-file-name p)))
732 dgnushack-default-load-path)))
735 (setq rest (cons (car path) rest)
736 path (delete (car rest) (cdr path))))
737 (setq path (nreverse (cdr (member lispdir rest)))
742 (when (file-exists-p (expand-file-name (pop elcs) (car path)))
743 (setq rest (cons (car path) rest)
745 (setq path (cdr path)))
747 (setq path (nreverse rest))
749 (let (print-level print-length)
751 WARNING: The other gnus installation" (if (cdr path) "s have" " has") "\
752 been detected in:\n\n " (mapconcat 'identity path "\n ") "\n\n\
753 You will need to modify the run-time `load-path', remove them manually,
754 or remove them using `make remove-installed-shadows'.\n\n"))))))))
756 (defun dgnushack-remove-lisp-shadows (&optional lispdir)
757 "Remove the other Gnus installations which shadow the recent one."
758 (let ((path (with-temp-buffer
759 (let ((standard-output (current-buffer)))
760 (dgnushack-find-lisp-shadows lispdir))))
761 elcs files shadows file)
763 (unless (setq elcs (directory-files srcdir nil "\\.elc\\'"))
764 (error "You should build .elc files first."))
770 (list (concat el "c") el (concat el ".bz2") (concat el ".gz")))
772 (list (file-name-nondirectory dgnushack-gnus-load-file)
773 (file-name-nondirectory dgnushack-cus-load-file))
774 (mapcar (lambda (elc) (substring elc 0 -1)) elcs)))))
778 (setq file (expand-file-name (pop shadows) (car path)))
779 (when (file-exists-p file)
780 (princ (concat " Removing " file "..."))
785 (error (princ "failed\n")))))
786 (setq path (cdr path))))))
788 ;;; dgnushack.el ends here