From 8f552dc868dbf405e5cae2ee22defa491ff6bffd Mon Sep 17 00:00:00 2001 From: Bill Wohler Date: Mon, 17 Oct 2005 05:52:53 +0000 Subject: [PATCH] (mh-image-load-path): Use locate-library to find MH-E. This simplified the code a lot. Flattened out nested statements even more. --- lisp/mh-e/ChangeLog | 6 ++++++ lisp/mh-e/mh-init.el | 42 ++++++++++++------------------------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index 093f5ee21ed..89f257ed2a3 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog @@ -1,3 +1,9 @@ +2005-10-16 Bill Wohler + + * mh-init.el (mh-image-load-path): Use locate-library to find + MH-E. This simplified the code a lot. Flattened out nested + statements even more. + 2005-10-16 Satyaki Das * mh-init.el (mh-image-load-path): Remove use of pushnew since it diff --git a/lisp/mh-e/mh-init.el b/lisp/mh-e/mh-init.el index 4b84e525725..dcc9af84e41 100644 --- a/lisp/mh-e/mh-init.el +++ b/lisp/mh-e/mh-init.el @@ -300,14 +300,6 @@ by the variable `mh-variants'." (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 @@ Images for MH-E are found in ../../etc/images relative to the files in `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) -- 2.39.5