summaryrefslogtreecommitdiff
path: root/lisp/image.el
diff options
context:
space:
mode:
authorBill Wohler <wohler@newt.com>2006-03-11 02:04:08 +0000
committerBill Wohler <wohler@newt.com>2006-03-11 02:04:08 +0000
commit20c65d08634a204bcf34b6ba29336f8223d15395 (patch)
tree29bc0fc491e4199a0450c7257915bf532568bbec /lisp/image.el
parent08f99a547c509e958a25782893251da277ea606f (diff)
downloademacs-20c65d08634a204bcf34b6ba29336f8223d15395.tar.gz
emacs-20c65d08634a204bcf34b6ba29336f8223d15395.tar.bz2
emacs-20c65d08634a204bcf34b6ba29336f8223d15395.zip
(image-load-path-for-library): Merged changes from Reiner. Add
no-error argument. If path t, just return directory.
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el22
1 files changed, 17 insertions, 5 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 4acff8d251b..2d7aea6fa0c 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -77,7 +77,7 @@ value is used as a list of directories to search.")
(list (file-name-as-directory (expand-file-name "images" data-directory))
'data-directory 'load-path)))
-(defun image-load-path-for-library (library image &optional path)
+(defun image-load-path-for-library (library image &optional path no-error)
"Return a suitable search path for images relative to LIBRARY.
Images for LIBRARY are searched for in \"../../etc/images\" and
@@ -85,8 +85,12 @@ Images for LIBRARY are searched for in \"../../etc/images\" and
well as in `image-load-path' and `load-path'.
This function returns the value of `load-path' augmented with the
-path to IMAGE. If PATH is given, it is used instead of
-`load-path'.
+directory containing IMAGE. If PATH is given, it is used instead
+of `load-path'. If PATH is t, just return the directory that
+contains IMAGE.
+
+If NO-ERROR is non-nil, return nil if a suitable path can't be
+found rather than signaling an error.
Here is an example that uses a common idiom to provide
compatibility with versions of Emacs that lack the variable
@@ -137,11 +141,19 @@ compatibility with versions of Emacs that lack the variable
(setq img (directory-file-name parent)
dir (expand-file-name "../" dir)))
(setq image-directory dir)))))
+ (no-error
+ ;; In this case we will return nil.
+ (message "Could not find image %s for library %s" image library))
(t
(error "Could not find image %s for library %s" image library)))
- ;; Return augmented `image-load-path' or `load-path'.
- (cond ((and path (symbolp path))
+ ;; Return the directory, nil if no-error was non-nil and a
+ ;; suitable path could not be found, or an augmented
+ ;; `image-load-path' or `load-path'.
+ (cond ((or (null image-directory)
+ (eq path t))
+ image-directory)
+ ((and path (symbolp path))
(nconc (list image-directory)
(delete image-directory
(if (boundp path)