Feedback from `t-gnus-6_15-quimby' branch.
[elisp/gnus.git-] / lisp / dgnushack.el
index c1aa474..5ae684b 100644 (file)
 
 (defvar srcdir (or (getenv "srcdir") "."))
 
-(let ((urldir (getenv "URLDIR")))
-  (unless (zerop (length urldir))
-    (push (file-name-as-directory urldir) load-path)))
-
 (defvar dgnushack-w3-directory (let ((w3dir (getenv "W3DIR")))
                                 (unless (zerop (length w3dir))
                                   (file-name-as-directory w3dir))))
-(when dgnushack-w3-directory
-  (push dgnushack-w3-directory load-path))
+
+(let ((urldir (getenv "URLDIR")))
+  (unless (zerop (length urldir))
+    (setq urldir (file-name-as-directory urldir))
+    (push (file-name-as-directory urldir) load-path))
+  (when (and dgnushack-w3-directory
+            (not (string-equal urldir dgnushack-w3-directory)))
+    (push dgnushack-w3-directory load-path)))
 
 ;; If we are building w3 in a different directory than the source
 ;; directory, we must read *.el from source directory and write *.elc
@@ -169,29 +171,40 @@ to the specified name LIBRARY (a la calling `load' instead of `load-library')."
 ;; Don't load path-util until `char-after' and `char-before' have been
 ;; optimized because it requires `poe' and then modify the functions.
 
-;; If the APEL modules have been installed under the directory
-;; "/usr/local/share/mule/site-lisp/apel/", the parent directory
-;; "/usr/local/share/mule/site-lisp/" should be included in the
-;; standard `load-path' or added by the configure option
-;; "--with-addpath=".  And also the directory where the EMU modules
-;; have been installed (e.g. "/usr/local/share/mule/19.34/site-lisp/")
-;; should be included in the standard `load-path' or added by the
-;; configure option "--with-addpath=".
-(unless (featurep 'path-util)
-  (let ((path (locate-library "apel/path-util")))
-    (if path
-       (progn
-         (when (string-match "/$" (setq path (file-name-directory path)))
-           (setq path (substring path 0 (match-beginning 0))))
-         (unless (or (member path load-path)
-                     (member (file-name-as-directory path) load-path))
-           (push path load-path))
-         (require 'path-util))
-      (error "
-APEL modules does not found in %s.
+;; 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))))
+          load-path)))
+
 (unless (locate-library "mel")
   (add-path "flim"))
 (unless (module-installed-p 'mel)
@@ -212,6 +225,10 @@ Try to re-configure with --with-addpath=FLIM_PATH and run make again.
 
 (load (expand-file-name "gnus-clfns.el" srcdir) nil t t)
 
+(when (boundp 'MULE)
+  ;; Load special macros for compiling canlock.el.
+  (load (expand-file-name "canlock-om.el" srcdir) nil t t))
+
 (require 'custom)
 
 ;; Bind functions defined by `defun-maybe'.
@@ -312,22 +329,23 @@ Try to re-configure with --with-addpath=FLIM_PATH and run make again.
                 (while (setq form (condition-case nil
                                       (read buffer)
                                     (error nil)))
-                  (while form
-                    (setq elem (pop form))
-                    (unless (memq (car-safe elem)
-                                  '(\` backquote
-                                    defcustom defface defgroup
-                                    define-widget quote))
-                      (while (consp elem)
-                        (push (car elem) form)
-                        (setq elem (cdr elem)))
-                      (when (and elem
-                                 (symbolp elem)
-                                 (not (eq ': elem))
-                                 (eq ?: (aref (symbol-name elem) 0))
-                                 (not (memq elem ignores))
-                                 (not (memq elem keywords)))
-                        (push elem keywords)))))))
+                  (when (listp form)
+                    (while form
+                      (setq elem (pop form))
+                      (unless (memq (car-safe elem)
+                                    '(\` backquote
+                                      defcustom defface defgroup
+                                      define-widget quote))
+                        (while (consp elem)
+                          (push (car elem) form)
+                          (setq elem (cdr elem)))
+                        (when (and elem
+                                   (symbolp elem)
+                                   (not (eq ': elem))
+                                   (eq ?: (aref (symbol-name elem) 0))
+                                   (not (memq elem ignores))
+                                   (not (memq elem keywords)))
+                          (push elem keywords))))))))
             (setq keywords (sort keywords
                                  (lambda (a b)
                                    (string-lessp (symbol-name a)
@@ -423,10 +441,10 @@ Try to re-configure with --with-addpath=FLIM_PATH and run make again.
              (progn (require 'shimbun) nil)
            (error '("nnshimbun.el")))
          (unless (or (condition-case code
-                         (require 'w3-forms)
+                         (require 'w3-parse)
                        (error
                         (message "No w3: %s %s retrying..." code
-                                 (locate-library "w3-forms"))
+                                 (locate-library "w3-parse"))
                         nil))
                      ;; Maybe mis-configured Makefile is used (e.g.
                      ;; configured for FSFmacs but XEmacs is running).
@@ -434,33 +452,44 @@ Try to re-configure with --with-addpath=FLIM_PATH and run make again.
                                        (copy-sequence load-path))))
                        (if (let ((load-path lp))
                              (condition-case nil
-                                 (require 'w3-forms)
+                                 (require 'w3-parse)
                                (error nil)))
                            ;; If success, fix `load-path' for compiling.
                            (progn
                              (setq load-path lp)
                              (message " => fixed; W3DIR=%s"
                                       (file-name-directory
-                                       (locate-library "w3-forms")))
+                                       (locate-library "w3-parse")))
                              t)
                          (message " => ignored")
                          nil)))
-           '("nnweb.el" "nnlistserv.el" "nnultimate.el"
-             "nnslashdot.el" "nnwarchive.el" "webmail.el"
-             "nnwfm.el" "nnrss.el"))
-         (condition-case nil
+           '("nnultimate.el" "webmail.el" "nnwfm.el"))
+         (condition-case code
+             (progn (require 'mh-e) nil)
+           (error
+            (message "No mh-e: %s %s (ignored)" code (locate-library "mh-e"))
+            '("gnus-mh.el")))
+         (condition-case code
+             (progn (require 'xml) nil)
+           (error
+            (message "No xml: %s %s (ignored)" code (locate-library "xml"))
+            '("nnrss.el")))
+         (condition-case code
              (progn (require 'bbdb) nil)
-           (error '("gnus-bbdb.el")))
+           (error
+            (message "No bbdb: %s %s (ignored)" code (locate-library "bbdb"))
+            '("gnus-bbdb.el")))
          (unless (featurep 'xemacs)
-           '("gnus-xmas.el" "gnus-picon.el" "messagexmas.el"
-             "nnheaderxm.el" "smiley.el"))
+           '("gnus-xmas.el" "messagexmas.el" "nnheaderxm.el" "smiley.el"))
          (when (or (featurep 'xemacs) (<= emacs-major-version 20))
            '("smiley-ems.el"))
          (when (and (fboundp 'base64-decode-string)
                     (subrp (symbol-function 'base64-decode-string)))
            '("base64.el"))
          (when (and (fboundp 'md5) (subrp (symbol-function 'md5)))
-           '("md5.el")))
+           '("md5.el"))
+         (unless (boundp 'MULE)
+           '("canlock-om.el")))
   "Files which will not be installed.")
 
 (defconst dgnushack-exporting-files
@@ -533,6 +562,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"))
@@ -617,7 +660,19 @@ Modify to suit your needs."))
 ;;; no-byte-compile: t
 ;;; no-update-autoloads: t
 ;;; End:
-;;; gnus-load.el ends here\n"))
+;;; gnus-load.el ends here
+")
+    ;; Workaround the bug in some version of XEmacs.
+    (when (featurep 'xemacs)
+      (condition-case nil
+         (require 'cus-load)
+       (error nil))
+      (goto-char (point-min))
+      (when (and (fboundp 'custom-add-loads)
+                (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
+       (search-forward "\n;;; Code:" nil t)
+       (forward-line 1)
+       (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
   (message (format "Compiling %s..." dgnushack-gnus-load-file))
   (byte-compile-file dgnushack-gnus-load-file))