diff options
| author | Bill Wohler | 2006-03-16 17:00:02 +0000 |
|---|---|---|
| committer | Bill Wohler | 2006-03-16 17:00:02 +0000 |
| commit | e8b5a7cebf76fb97b7da34d63837bcd2c55d310a (patch) | |
| tree | 087669420f3856b71211ca2264327c4c6c58adeb | |
| parent | 486daaa504ab18287be24fa86a72d91b81fae564 (diff) | |
| download | emacs-e8b5a7cebf76fb97b7da34d63837bcd2c55d310a.tar.gz emacs-e8b5a7cebf76fb97b7da34d63837bcd2c55d310a.zip | |
(mh-image-load-path-for-library): Prefer user's images.
| -rw-r--r-- | lisp/mh-e/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/mh-e/mh-compat.el | 70 |
2 files changed, 48 insertions, 27 deletions
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index 0398d79b922..f9c392724ae 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2006-03-16 Bill Wohler <wohler@newt.com> | ||
| 2 | |||
| 3 | * mh-compat.el (mh-image-load-path-for-library): Prefer user's | ||
| 4 | images. | ||
| 5 | |||
| 1 | 2006-03-15 Bill Wohler <wohler@newt.com> | 6 | 2006-03-15 Bill Wohler <wohler@newt.com> |
| 2 | 7 | ||
| 3 | * mh-compat.el (mh-image-load-path-for-library): Fix example by | 8 | * mh-compat.el (mh-image-load-path-for-library): Fix example by |
diff --git a/lisp/mh-e/mh-compat.el b/lisp/mh-e/mh-compat.el index d4da371bffc..5e94d72e0b0 100644 --- a/lisp/mh-e/mh-compat.el +++ b/lisp/mh-e/mh-compat.el | |||
| @@ -119,10 +119,11 @@ introduced in Emacs 22." | |||
| 119 | image-load-path-for-library (library image &optional path no-error) | 119 | image-load-path-for-library (library image &optional path no-error) |
| 120 | "Return a suitable search path for images relative to LIBRARY. | 120 | "Return a suitable search path for images relative to LIBRARY. |
| 121 | 121 | ||
| 122 | First it searches for IMAGE in a path suitable for LIBRARY, which | 122 | First it searches for IMAGE in `image-load-path' (excluding |
| 123 | includes \"../../etc/images\" and \"../etc/images\" relative to | 123 | \"`data-directory'/images\") and `load-path', followed by a path |
| 124 | the library file itself, followed by `image-load-path' and | 124 | suitable for LIBRARY, which includes \"../../etc/images\" and |
| 125 | `load-path'. | 125 | \"../etc/images\" relative to the library file itself, and then |
| 126 | in \"`data-directory'/images\". | ||
| 126 | 127 | ||
| 127 | Then this function returns a list of directories which contains | 128 | Then this function returns a list of directories which contains |
| 128 | first the directory in which IMAGE was found, followed by the | 129 | first the directory in which IMAGE was found, followed by the |
| @@ -147,8 +148,36 @@ compatibility with versions of Emacs that lack the variable | |||
| 147 | (mh-tool-bar-folder-buttons-init))" | 148 | (mh-tool-bar-folder-buttons-init))" |
| 148 | (unless library (error "No library specified")) | 149 | (unless library (error "No library specified")) |
| 149 | (unless image (error "No image specified")) | 150 | (unless image (error "No image specified")) |
| 150 | (let ((image-directory)) | 151 | (let (image-directory image-directory-load-path) |
| 152 | ;; Check for images in image-load-path or load-path. | ||
| 153 | (let ((img image) | ||
| 154 | (dir (or | ||
| 155 | ;; Images in image-load-path. | ||
| 156 | (mh-image-search-load-path image) | ||
| 157 | ;; Images in load-path. | ||
| 158 | (locate-library image))) | ||
| 159 | parent) | ||
| 160 | ;; Since the image might be in a nested directory (for | ||
| 161 | ;; example, mail/attach.pbm), adjust `image-directory' | ||
| 162 | ;; accordingly. | ||
| 163 | (when dir | ||
| 164 | (setq dir (file-name-directory dir)) | ||
| 165 | (while (setq parent (file-name-directory img)) | ||
| 166 | (setq img (directory-file-name parent) | ||
| 167 | dir (expand-file-name "../" dir)))) | ||
| 168 | (setq image-directory-load-path dir)) | ||
| 169 | |||
| 170 | ;; If `image-directory-load-path' isn't Emacs' image directory, | ||
| 171 | ;; it's probably a user preference, so use it. Then use a | ||
| 172 | ;; relative setting if possible; otherwise, use | ||
| 173 | ;; `image-directory-load-path'. | ||
| 151 | (cond | 174 | (cond |
| 175 | ;; User-modified image-load-path? | ||
| 176 | ((and image-directory-load-path | ||
| 177 | (not (equal image-directory-load-path | ||
| 178 | (file-name-as-directory | ||
| 179 | (expand-file-name "images" data-directory))))) | ||
| 180 | (setq image-directory image-directory-load-path)) | ||
| 152 | ;; Try relative setting. | 181 | ;; Try relative setting. |
| 153 | ((let (library-name d1ei d2ei) | 182 | ((let (library-name d1ei d2ei) |
| 154 | ;; First, find library in the load-path. | 183 | ;; First, find library in the load-path. |
| @@ -158,33 +187,20 @@ compatibility with versions of Emacs that lack the variable | |||
| 158 | ;; And then set image-directory relative to that. | 187 | ;; And then set image-directory relative to that. |
| 159 | (setq | 188 | (setq |
| 160 | ;; Go down 2 levels. | 189 | ;; Go down 2 levels. |
| 161 | d2ei (expand-file-name | 190 | d2ei (file-name-as-directory |
| 162 | (concat (file-name-directory library-name) "../../etc/images")) | 191 | (expand-file-name |
| 192 | (concat (file-name-directory library-name) "../../etc/images"))) | ||
| 163 | ;; Go down 1 level. | 193 | ;; Go down 1 level. |
| 164 | d1ei (expand-file-name | 194 | d1ei (file-name-as-directory |
| 165 | (concat (file-name-directory library-name) "../etc/images"))) | 195 | (expand-file-name |
| 196 | (concat (file-name-directory library-name) "../etc/images")))) | ||
| 166 | (setq image-directory | 197 | (setq image-directory |
| 167 | ;; Set it to nil if image is not found. | 198 | ;; Set it to nil if image is not found. |
| 168 | (cond ((file-exists-p (expand-file-name image d2ei)) d2ei) | 199 | (cond ((file-exists-p (expand-file-name image d2ei)) d2ei) |
| 169 | ((file-exists-p (expand-file-name image d1ei)) d1ei))))) | 200 | ((file-exists-p (expand-file-name image d1ei)) d1ei))))) |
| 170 | ;; Check for images in image-load-path or load-path. | 201 | ;; Use Emacs' image directory. |
| 171 | ((let ((img image) | 202 | (image-directory-load-path |
| 172 | (dir (or | 203 | (setq image-directory image-directory-load-path)) |
| 173 | ;; Images in image-load-path. | ||
| 174 | (mh-image-search-load-path image) | ||
| 175 | ;; Images in load-path. | ||
| 176 | (locate-library image))) | ||
| 177 | parent) | ||
| 178 | ;; Since the image might be in a nested directory (for | ||
| 179 | ;; example, mail/attach.pbm), adjust `image-directory' | ||
| 180 | ;; accordingly. | ||
| 181 | (and dir | ||
| 182 | (setq dir (file-name-directory dir)) | ||
| 183 | (progn | ||
| 184 | (while (setq parent (file-name-directory img)) | ||
| 185 | (setq img (directory-file-name parent) | ||
| 186 | dir (expand-file-name "../" dir))) | ||
| 187 | (setq image-directory dir))))) | ||
| 188 | (no-error | 204 | (no-error |
| 189 | (message "Could not find image %s for library %s" image library)) | 205 | (message "Could not find image %s for library %s" image library)) |
| 190 | (t | 206 | (t |