diff options
| author | Bill Wohler | 2006-03-14 19:16:24 +0000 |
|---|---|---|
| committer | Bill Wohler | 2006-03-14 19:16:24 +0000 |
| commit | 5248a565cad8ca4a489fb8e8cd1bd21a2cf8f006 (patch) | |
| tree | c42687b0e667770d123227156e11196a70118da7 | |
| parent | c852c516e024765752eb63fb197480a37633241f (diff) | |
| download | emacs-5248a565cad8ca4a489fb8e8cd1bd21a2cf8f006.tar.gz emacs-5248a565cad8ca4a489fb8e8cd1bd21a2cf8f006.zip | |
(image-load-path-for-library): Pass value of path rather than symbol.
Always return list of directories. Guarantee that image directory
comes first.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/image.el | 52 |
2 files changed, 28 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7c796211e96..ef7613f6b9d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2006-03-14 Bill Wohler <wohler@newt.com> | ||
| 2 | |||
| 3 | * image.el (image-load-path-for-library): Pass value of path | ||
| 4 | rather than symbol. Always return list of directories. Guarantee | ||
| 5 | that image directory comes first. | ||
| 6 | |||
| 1 | 2006-03-14 Alan Mackenzie <acm@muc.de> | 7 | 2006-03-14 Alan Mackenzie <acm@muc.de> |
| 2 | 8 | ||
| 3 | * font-core.el: New function/variable | 9 | * font-core.el: New function/variable |
diff --git a/lisp/image.el b/lisp/image.el index 2d7aea6fa0c..6938dba05cb 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -77,30 +77,34 @@ value is used as a list of directories to search.") | |||
| 77 | (list (file-name-as-directory (expand-file-name "images" data-directory)) | 77 | (list (file-name-as-directory (expand-file-name "images" data-directory)) |
| 78 | 'data-directory 'load-path))) | 78 | 'data-directory 'load-path))) |
| 79 | 79 | ||
| 80 | |||
| 80 | (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) |
| 81 | "Return a suitable search path for images relative to LIBRARY. | 82 | "Return a suitable search path for images relative to LIBRARY. |
| 82 | 83 | ||
| 83 | Images for LIBRARY are searched for in \"../../etc/images\" and | 84 | First it searches for IMAGE in a path suitable for LIBRARY, which |
| 84 | \"../etc/images\" relative to the files in \"lisp/LIBRARY\" as | 85 | includes \"../../etc/images\" and \"../etc/images\" relative to |
| 85 | well as in `image-load-path' and `load-path'. | 86 | the library file itself, followed by `image-load-path' and |
| 87 | `load-path'. | ||
| 86 | 88 | ||
| 87 | This function returns the value of `load-path' augmented with the | 89 | Then this function returns a list of directories which contains |
| 88 | directory containing IMAGE. If PATH is given, it is used instead | 90 | first the directory in which IMAGE was found, followed by the |
| 89 | of `load-path'. If PATH is t, just return the directory that | 91 | value of `load-path'. If PATH is given, it is used instead of |
| 90 | contains IMAGE. | 92 | `load-path'. |
| 91 | 93 | ||
| 92 | If NO-ERROR is non-nil, return nil if a suitable path can't be | 94 | If NO-ERROR is non-nil and a suitable path can't be found, don't |
| 93 | found rather than signaling an error. | 95 | signal an error. Instead, return a list of directories as before, |
| 96 | except that nil appears in place of the image directory. | ||
| 94 | 97 | ||
| 95 | Here is an example that uses a common idiom to provide | 98 | Here is an example that uses a common idiom to provide |
| 96 | compatibility with versions of Emacs that lack the variable | 99 | compatibility with versions of Emacs that lack the variable |
| 97 | `image-load-path': | 100 | `image-load-path': |
| 98 | 101 | ||
| 99 | (let ((load-path | 102 | ;; Avoid errors on Emacsen without `image-load-path'. |
| 100 | (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\")) | 103 | (if (not (boundp 'image-load-path)) (defvar image-load-path nil)) |
| 101 | (image-load-path | 104 | |
| 102 | (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\" 'image-load-path))) | 105 | (let* ((load-path (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\")) |
| 103 | (mh-tool-bar-folder-buttons-init))" | 106 | (image-load-path (cons (car load-path) image-load-path))) |
| 107 | (mh-tool-bar-folder-buttons-init))" | ||
| 104 | (unless library (error "No library specified")) | 108 | (unless library (error "No library specified")) |
| 105 | (unless image (error "No image specified")) | 109 | (unless image (error "No image specified")) |
| 106 | (let ((image-directory)) | 110 | (let ((image-directory)) |
| @@ -142,26 +146,14 @@ compatibility with versions of Emacs that lack the variable | |||
| 142 | dir (expand-file-name "../" dir))) | 146 | dir (expand-file-name "../" dir))) |
| 143 | (setq image-directory dir))))) | 147 | (setq image-directory dir))))) |
| 144 | (no-error | 148 | (no-error |
| 145 | ;; In this case we will return nil. | ||
| 146 | (message "Could not find image %s for library %s" image library)) | 149 | (message "Could not find image %s for library %s" image library)) |
| 147 | (t | 150 | (t |
| 148 | (error "Could not find image %s for library %s" image library))) | 151 | (error "Could not find image %s for library %s" image library))) |
| 149 | 152 | ||
| 150 | ;; Return the directory, nil if no-error was non-nil and a | 153 | ;; Return an augmented `path' or `load-path'. |
| 151 | ;; suitable path could not be found, or an augmented | 154 | (nconc (list image-directory) |
| 152 | ;; `image-load-path' or `load-path'. | 155 | (delete image-directory (copy-sequence (or path load-path)))))) |
| 153 | (cond ((or (null image-directory) | 156 | |
| 154 | (eq path t)) | ||
| 155 | image-directory) | ||
| 156 | ((and path (symbolp path)) | ||
| 157 | (nconc (list image-directory) | ||
| 158 | (delete image-directory | ||
| 159 | (if (boundp path) | ||
| 160 | (copy-sequence (symbol-value path)) | ||
| 161 | nil)))) | ||
| 162 | (t | ||
| 163 | (nconc (list image-directory) | ||
| 164 | (delete image-directory (copy-sequence load-path))))))) | ||
| 165 | 157 | ||
| 166 | (defun image-jpeg-p (data) | 158 | (defun image-jpeg-p (data) |
| 167 | "Value is non-nil if DATA, a string, consists of JFIF image data. | 159 | "Value is non-nil if DATA, a string, consists of JFIF image data. |