aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wohler2006-03-16 16:55:26 +0000
committerBill Wohler2006-03-16 16:55:26 +0000
commitc0696e1b955ce2f22821a28c33aeebda481b4419 (patch)
treee25bcac850b3b215e77490b09dc473ee7c913b50
parent39f89139fad1ba38c3828c1cf18d0fb206405e1e (diff)
downloademacs-c0696e1b955ce2f22821a28c33aeebda481b4419.tar.gz
emacs-c0696e1b955ce2f22821a28c33aeebda481b4419.zip
(image-load-path-for-library): Prefer user's images in
image-load-path.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/image.el70
2 files changed, 48 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 07a3e4488ab..28a7d0b808b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12006-03-16 Bill Wohler <wohler@newt.com>
2
3 * image.el (image-load-path-for-library): Prefer user's images in
4 image-load-path.
5
12006-03-16 Martin Rudalics <rudalics@gmx.at> 62006-03-16 Martin Rudalics <rudalics@gmx.at>
2 7
3 * mouse.el (mouse-drag-vertical-line): Use window-inside-edges 8 * mouse.el (mouse-drag-vertical-line): Use window-inside-edges
diff --git a/lisp/image.el b/lisp/image.el
index a01497ff445..357450ec473 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -81,10 +81,11 @@ value is used as a list of directories to search.")
81(defun image-load-path-for-library (library image &optional path no-error) 81(defun image-load-path-for-library (library image &optional path no-error)
82 "Return a suitable search path for images relative to LIBRARY. 82 "Return a suitable search path for images relative to LIBRARY.
83 83
84First it searches for IMAGE in a path suitable for LIBRARY, which 84First it searches for IMAGE in `image-load-path' (excluding
85includes \"../../etc/images\" and \"../etc/images\" relative to 85\"`data-directory'/images\") and `load-path', followed by a path
86the library file itself, followed by `image-load-path' and 86suitable for LIBRARY, which includes \"../../etc/images\" and
87`load-path'. 87\"../etc/images\" relative to the library file itself, and then
88in \"`data-directory'/images\".
88 89
89Then this function returns a list of directories which contains 90Then this function returns a list of directories which contains
90first the directory in which IMAGE was found, followed by the 91first the directory in which IMAGE was found, followed by the
@@ -109,8 +110,36 @@ compatibility with versions of Emacs that lack the variable
109 (mh-tool-bar-folder-buttons-init))" 110 (mh-tool-bar-folder-buttons-init))"
110 (unless library (error "No library specified")) 111 (unless library (error "No library specified"))
111 (unless image (error "No image specified")) 112 (unless image (error "No image specified"))
112 (let ((image-directory)) 113 (let (image-directory image-directory-load-path)
114 ;; Check for images in image-load-path or load-path.
115 (let ((img image)
116 (dir (or
117 ;; Images in image-load-path.
118 (image-search-load-path image)
119 ;; Images in load-path.
120 (locate-library image)))
121 parent)
122 ;; Since the image might be in a nested directory (for
123 ;; example, mail/attach.pbm), adjust `image-directory'
124 ;; accordingly.
125 (when dir
126 (setq dir (file-name-directory dir))
127 (while (setq parent (file-name-directory img))
128 (setq img (directory-file-name parent)
129 dir (expand-file-name "../" dir))))
130 (setq image-directory-load-path dir))
131
132 ;; If `image-directory-load-path' isn't Emacs' image directory,
133 ;; it's probably a user preference, so use it. Then use a
134 ;; relative setting if possible; otherwise, use
135 ;; `image-directory-load-path'.
113 (cond 136 (cond
137 ;; User-modified image-load-path?
138 ((and image-directory-load-path
139 (not (equal image-directory-load-path
140 (file-name-as-directory
141 (expand-file-name "images" data-directory)))))
142 (setq image-directory image-directory-load-path))
114 ;; Try relative setting. 143 ;; Try relative setting.
115 ((let (library-name d1ei d2ei) 144 ((let (library-name d1ei d2ei)
116 ;; First, find library in the load-path. 145 ;; First, find library in the load-path.
@@ -120,33 +149,20 @@ compatibility with versions of Emacs that lack the variable
120 ;; And then set image-directory relative to that. 149 ;; And then set image-directory relative to that.
121 (setq 150 (setq
122 ;; Go down 2 levels. 151 ;; Go down 2 levels.
123 d2ei (expand-file-name 152 d2ei (file-name-as-directory
124 (concat (file-name-directory library-name) "../../etc/images")) 153 (expand-file-name
154 (concat (file-name-directory library-name) "../../etc/images")))
125 ;; Go down 1 level. 155 ;; Go down 1 level.
126 d1ei (expand-file-name 156 d1ei (file-name-as-directory
127 (concat (file-name-directory library-name) "../etc/images"))) 157 (expand-file-name
158 (concat (file-name-directory library-name) "../etc/images"))))
128 (setq image-directory 159 (setq image-directory
129 ;; Set it to nil if image is not found. 160 ;; Set it to nil if image is not found.
130 (cond ((file-exists-p (expand-file-name image d2ei)) d2ei) 161 (cond ((file-exists-p (expand-file-name image d2ei)) d2ei)
131 ((file-exists-p (expand-file-name image d1ei)) d1ei))))) 162 ((file-exists-p (expand-file-name image d1ei)) d1ei)))))
132 ;; Check for images in image-load-path or load-path. 163 ;; Use Emacs' image directory.
133 ((let ((img image) 164 (image-directory-load-path
134 (dir (or 165 (setq image-directory image-directory-load-path))
135 ;; Images in image-load-path.
136 (image-search-load-path image)
137 ;; Images in load-path.
138 (locate-library image)))
139 parent)
140 ;; Since the image might be in a nested directory (for
141 ;; example, mail/attach.pbm), adjust `image-directory'
142 ;; accordingly.
143 (and dir
144 (setq dir (file-name-directory dir))
145 (progn
146 (while (setq parent (file-name-directory img))
147 (setq img (directory-file-name parent)
148 dir (expand-file-name "../" dir)))
149 (setq image-directory dir)))))
150 (no-error 166 (no-error
151 (message "Could not find image %s for library %s" image library)) 167 (message "Could not find image %s for library %s" image library))
152 (t 168 (t