Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / dgnushack.el
index 676ad2d..3496035 100644 (file)
 
 (require 'bytecomp)
 
+(when (boundp 'MULE)
+  (let (current-load-list)
+    ;; Make the function to be silent at compile-time.
+    (defun locate-library (library &optional nosuffix)
+      "Show the full path name of Emacs library LIBRARY.
+This command searches the directories in `load-path' like `M-x load-library'
+to find the file that `M-x load-library RET LIBRARY RET' would load.
+Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
+to the specified name LIBRARY (a la calling `load' instead of `load-library')."
+      (interactive "sLocate library: ")
+      (catch 'answer
+       (mapcar
+        '(lambda (dir)
+           (mapcar
+            '(lambda (suf)
+               (let ((try (expand-file-name (concat library suf) dir)))
+                 (and (file-readable-p try)
+                      (null (file-directory-p try))
+                      (progn
+                        (or noninteractive
+                            (message "Library is file %s" try))
+                        (throw 'answer try)))))
+            (if nosuffix '("") '(".elc" ".el" ""))))
+        load-path)
+       (or noninteractive
+           (message "No library %s in search path" library))
+       nil))
+    (byte-compile 'locate-library)))
+
 (unless (fboundp 'si:byte-optimize-form-code-walker)
   (byte-optimize-form nil);; Load `byte-opt' or `byte-optimize'.
   (setq max-specpdl-size 3000)
 
 ;; Don't load path-util until `char-after' and `char-before' have been
 ;; optimized because it requires `poe' and then modify the functions.
-(or (featurep 'path-util)
-    (load "apel/path-util"))
-(add-path "apel")
-(add-path "flim")
+
+;; If the APEL modules are installed under the non-standard directory,
+;; for example "/var/home/john/lisp/apel-VERSION/", you should add that
+;; name using the configure option "--with-addpath=".
+;; And also the directory where the EMU modules are installed, for
+;; example "/usr/local/share/mule/19.34/site-lisp/", it should be
+;; included in the standard `load-path' or added by the configure
+;; option "--with-addpath=".
+(let ((path (or (locate-library "path-util")
+               (locate-library "apel/path-util")));; backward compat.
+      parent lpath)
+  (if path
+      (progn
+       (when (string-match "/$" (setq path (file-name-directory path)))
+         (setq path (substring path 0 (match-beginning 0))))
+       ;; path == "/var/home/john/lisp/apel-VERSION"
+       (when (string-match "/$" (setq parent (file-name-directory path)))
+         (setq parent (substring path 0 (match-beginning 0))))
+       ;; parent == "/var/home/john/lisp"
+       (if (setq lpath (or (member path load-path)
+                           (member (file-name-as-directory path) load-path)))
+           (unless (or (member parent load-path)
+                       (member (file-name-as-directory parent) load-path))
+             (push parent (cdr lpath)))
+         (push path load-path)
+         (unless (or (member parent load-path)
+                     (member (file-name-as-directory parent) load-path))
+           (push parent (cdr load-path))))
+       (require 'path-util))
+    (error "
+APEL modules are not found in %s.
+Try to re-configure with --with-addpath=APEL_PATH and run make again.
+"
+          load-path)))
+
+(unless (locate-library "mel")
+  (add-path "flim"))
 (unless (module-installed-p 'mel)
   ;; FLIM 1.14 may have installed in two "flim" subdirectories.
   (push (expand-file-name "flim"
        load-path)
   (unless (module-installed-p 'mel)
     (error "
-FLIM package does not found in %s.
+FLIM modules does not found in %s.
 Try to re-configure with --with-addpath=FLIM_PATH and run make again.
 "
-          (progn
-            (add-path "semi")
-            load-path))))
+          load-path)))
 (add-path "semi")
 
 (push srcdir load-path)
@@ -176,35 +236,6 @@ Try to re-configure with --with-addpath=FLIM_PATH and run make again.
                  byte-compile-function-environment)))
   form)
 
-(when (boundp 'MULE)
-  (let (current-load-list)
-    ;; Make the function to be silent at compile-time.
-    (defun locate-library (library &optional nosuffix)
-      "Show the full path name of Emacs library LIBRARY.
-This command searches the directories in `load-path' like `M-x load-library'
-to find the file that `M-x load-library RET LIBRARY RET' would load.
-Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
-to the specified name LIBRARY (a la calling `load' instead of `load-library')."
-      (interactive "sLocate library: ")
-      (catch 'answer
-       (mapcar
-        '(lambda (dir)
-           (mapcar
-            '(lambda (suf)
-               (let ((try (expand-file-name (concat library suf) dir)))
-                 (and (file-readable-p try)
-                      (null (file-directory-p try))
-                      (progn
-                        (or noninteractive
-                            (message "Library is file %s" try))
-                        (throw 'answer try)))))
-            (if nosuffix '("") '(".elc" ".el" ""))))
-        load-path)
-       (or noninteractive
-           (message "No library %s in search path" library))
-       nil))
-    (byte-compile 'locate-library)))
-
 (condition-case nil
     :symbol-for-testing-whether-colon-keyword-is-available-or-not
   (void-variable
@@ -295,9 +326,9 @@ to the specified name LIBRARY (a la calling `load' instead of `load-library')."
                   (while form
                     (setq elem (pop form))
                     (unless (memq (car-safe elem)
-                                  '(\` backquote defcustom define-widget
-                                    quote widget-convert-button
-                                    widget-create widget-put))
+                                  '(\` backquote
+                                    defcustom defface defgroup
+                                    define-widget quote))
                       (while (consp elem)
                         (push (car elem) form)
                         (setq elem (cdr elem)))
@@ -399,6 +430,9 @@ to the specified name LIBRARY (a la calling `load' instead of `load-library')."
 
 (defconst dgnushack-unexporting-files
   (append '("dgnushack.el" "dgnuspath.el" "dgnuskwds.el" "lpath.el")
+         (condition-case nil
+             (progn (require 'shimbun) nil)
+           (error '("nnshimbun.el")))
          (unless (or (condition-case code
                          (require 'w3-forms)
                        (error
@@ -510,6 +544,20 @@ Modify to suit your needs."))
 
 (defun dgnushack-make-auto-load ()
   (require 'autoload)
+  (unless (make-autoload '(define-derived-mode child parent name
+                           "docstring" body)
+                        "file")
+    (defadvice make-autoload (around handle-define-derived-mode activate)
+      "Handle `define-derived-mode'."
+      (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
+         (setq ad-return-value
+               (list 'autoload
+                     (list 'quote (nth 1 (ad-get-arg 0)))
+                     (ad-get-arg 1)
+                     (nth 4 (ad-get-arg 0))
+                     t nil))
+       ad-do-it))
+    (put 'define-derived-mode 'doc-string-elt 3))
   (let ((generated-autoload-file dgnushack-gnus-load-file)
        (make-backup-files nil)
        (autoload-package-name "gnus"))