diff lisp/mh-e/mh-init.el @ 66136:aacff8293f4b

(mh-image-load-path): Use locate-library to find MH-E. This simplified the code a lot. Flattened out nested statements even more.
author Bill Wohler <wohler@newt.com>
date Mon, 17 Oct 2005 05:52:53 +0000
parents debb27ca9375
children 25ad3e63f2a1
line wrap: on
line diff
--- a/lisp/mh-e/mh-init.el	Mon Oct 17 04:46:46 2005 +0000
+++ b/lisp/mh-e/mh-init.el	Mon Oct 17 05:52:53 2005 +0000
@@ -300,14 +300,6 @@
                     (add-to-list 'mh-variants variant)))))
       mh-variants)))
 
-;;; XXX The two calls to message in this function should really be calls to
-;;; error. However, when this function is compiled via the top-level call in
-;;; mh-customize.el, it is actually called, and in a compile environment, the
-;;; errors are triggered which botches the compile. As a workaround, the calls
-;;; to error have been changed to calls to message, and code following was
-;;; inserted as an else clause. This is not robust, so if you can fix this,
-;;; please do!
-
 (defvar mh-image-load-path-called-flag nil)
 
 ;;;###mh-autoload
@@ -317,30 +309,20 @@
 `lisp/mh-e'. If `image-load-path' exists (since Emacs 22), then the images
 directory is added to it if isn't already there. Otherwise, the images
 directory is added to the `load-path' if it isn't already there."
-  (message "mh-image-load-path called") ;XXX: for debugging
   (unless mh-image-load-path-called-flag
-    (let (mh-load-path mh-image-load-path)
+    (let (mh-library-name mh-image-load-path)
       ;; First, find mh-e in the load-path.
-      (setq mh-load-path
-            (loop for dir in load-path
-                  for dir-name = (directory-file-name dir)
-                  when (and (equal (file-name-nondirectory dir-name) "mh-e")
-                            (file-exists-p dir-name))
-                  return dir-name))
-      (if mh-load-path
-          (setq mh-image-load-path
-                (expand-file-name (concat (file-name-directory mh-load-path)
-                                          "../etc/images")))
-        (error "Can not find mh-e in load-path"))
-      (cond ((or (not mh-image-load-path)
-                 (not (file-exists-p mh-image-load-path)))
-             (error "Can not find image directory %s"
-                    mh-image-load-path))
-            ((boundp 'image-load-path)
-             (unless (member mh-image-load-path image-load-path)
-               (push mh-image-load-path image-load-path)))
-            ((not (member mh-image-load-path load-path))
-             (push mh-image-load-path load-path))))
+      (setq mh-library-name (locate-library "mh-e"))
+      (if (not mh-library-name)
+        (error "Can not find MH-E in load-path"))
+      (setq mh-image-load-path
+            (expand-file-name (concat (file-name-directory mh-library-name)
+                                      "../../etc/images")))
+      (if (not (file-exists-p mh-image-load-path))
+          (error "Can not find image directory %s" mh-image-load-path))
+      (if (boundp 'image-load-path)
+          (add-to-list 'image-load-path mh-image-load-path)
+        (add-to-list 'load-path mh-image-load-path)))
     (setq mh-image-load-path-called-flag t)))
 
 (provide 'mh-init)