Commit 2416ec64 authored by Satyaki Das's avatar Satyaki Das
Browse files

* mh-init.el (mh-image-load-path-called-flag): New variable which

is used by mh-image-load-path so that it runs only once.
(mh-image-load-path): Modified so that it gets run only once. Also
flatten out heavily nested if statements to make it clearer.

* mh-e.el (mh-folder-mode): Call mh-image-load-path to allow Emacs
to find images used in the toolbar.

* mh-customize.el (:folder): Remove call to mh-image-load-path.
parent 2ef1363e
2005-10-15 Satyaki Das <satyaki@theforce.stanford.edu>
* mh-init.el (mh-image-load-path-called-flag): New variable which
is used by mh-image-load-path so that it runs only once.
(mh-image-load-path): Modified so that it gets run only once. Also
flatten out heavily nested if statements to make it clearer.
* mh-e.el (mh-folder-mode): Call mh-image-load-path to allow Emacs
to find images used in the toolbar.
* mh-customize.el (:folder): Remove call to mh-image-load-path.
2005-10-14 Bill Wohler <wohler@newt.com> 2005-10-14 Bill Wohler <wohler@newt.com>
* mh-e.el (Version, mh-version): Added +cvs to version. * mh-e.el (Version, mh-version): Added +cvs to version.
......
...@@ -1897,7 +1897,6 @@ where, ...@@ -1897,7 +1897,6 @@ where,
for y in letter-docs for y in letter-docs
collect `(const :tag ,y ,x))))))) collect `(const :tag ,y ,x)))))))
(mh-image-load-path)
(mh-tool-bar-define (mh-tool-bar-define
((:folder mh-inc-folder mh-mime-save-parts mh-previous-undeleted-msg ((:folder mh-inc-folder mh-mime-save-parts mh-previous-undeleted-msg
mh-page-msg mh-next-undeleted-msg mh-delete-msg mh-refile-msg mh-page-msg mh-next-undeleted-msg mh-delete-msg mh-refile-msg
......
...@@ -1561,6 +1561,7 @@ messages in that region. ...@@ -1561,6 +1561,7 @@ messages in that region.
\\{mh-folder-mode-map}" \\{mh-folder-mode-map}"
(mh-image-load-path)
(make-local-variable 'font-lock-defaults) (make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(mh-folder-font-lock-keywords t)) (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
(make-local-variable 'desktop-save-buffer) (make-local-variable 'desktop-save-buffer)
......
...@@ -307,6 +307,9 @@ by the variable `mh-variants'." ...@@ -307,6 +307,9 @@ by the variable `mh-variants'."
;;; to error have been changed to calls to message, and code following was ;;; 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, ;;; inserted as an else clause. This is not robust, so if you can fix this,
;;; please do! ;;; please do!
(defvar mh-image-load-path-called-flag nil)
;;;###mh-autoload ;;;###mh-autoload
(defun mh-image-load-path () (defun mh-image-load-path ()
"Ensure that the MH-E images are accessible by `find-image'. "Ensure that the MH-E images are accessible by `find-image'.
...@@ -314,36 +317,30 @@ Images for MH-E are found in ../../etc/images relative to the files in ...@@ -314,36 +317,30 @@ 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 `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 it if isn't already there. Otherwise, the images
directory is added to the `load-path' if it isn't already there." directory is added to the `load-path' if it isn't already there."
(let (mh-load-path mh-image-load-path) (message "mh-image-load-path called") ;XXX: for debugging
;; First, find mh-e in the load-path. (unless mh-image-load-path-called-flag
(let ((path load-path)) (let (mh-load-path mh-image-load-path)
(while path ;; First, find mh-e in the load-path.
(let* ((directory (directory-file-name (car path)))) (setq mh-load-path
(setq mh-load-path (loop for dir in load-path
(if (and (equal (file-name-nondirectory directory) "mh-e") for dir-name = (directory-file-name dir)
(file-exists-p directory)) when (and (equal (file-name-nondirectory dir-name) "mh-e")
directory (file-exists-p dir-name))
nil)) return dir-name))
(setq path (if mh-load-path nil (cdr path))))) (if mh-load-path
(if (not mh-load-path) (setq mh-image-load-path
;; This message be error; there shouldn't be an else. Blame compiler. (expand-file-name (concat (file-name-directory mh-load-path)
(message "Can not find mh-e in load-path (OK when compiling)") "../etc/images")))
;; Create the image path associated with this mh-e directory. (error "Can not find mh-e in load-path"))
(setq mh-image-load-path (expand-file-name (cond ((or (not mh-image-load-path)
(concat (file-name-directory mh-load-path) (not (file-exists-p mh-image-load-path)))
"../etc/images"))))) (error "Can not find image directory %s"
(if (or (not mh-image-load-path) mh-image-load-path))
(not (file-exists-p mh-image-load-path))) ((boundp 'image-load-path)
;; This message be error; there shouldn't be an else. Blame compiler. (pushnew mh-image-load-path image-load-path))
(message "Can not find image directory %s (OK when compiling)" ((not (member mh-image-load-path load-path))
mh-image-load-path) (push mh-image-load-path load-path))))
;; If image-load-path exists, and the image path isn't there add it. (setq mh-image-load-path-called-flag t)))
(if (boundp 'image-load-path)
(if (not (member mh-image-load-path image-load-path))
(push mh-image-load-path image-load-path))
;; Otherwise, if the image path isn't in the load-path, add it there.
(if (not (member mh-image-load-path load-path))
(push mh-image-load-path load-path))))))
(provide 'mh-init) (provide 'mh-init)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment