aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-06-06 14:27:42 +0000
committerDave Love2000-06-06 14:27:42 +0000
commitcedbd8d02f7893a32ed841cc4819ae3924c1cd9b (patch)
tree2265c1d7bf0406f592d6fda31bbd8931ccf48878
parenta57a1605523357cfea72fc15a36c51e69321e83a (diff)
downloademacs-cedbd8d02f7893a32ed841cc4819ae3924c1cd9b.tar.gz
emacs-cedbd8d02f7893a32ed841cc4819ae3924c1cd9b.zip
(find-image): Doc fix. Return nil if image not found.
(put-image, insert-image): Make STRING arg optional.
-rw-r--r--lisp/image.el35
1 files changed, 22 insertions, 13 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 0c1e54a702b..9b04784ec00 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -111,19 +111,20 @@ Value is the image created, or nil if images of type TYPE are not supported."
111 111
112 112
113;;;###autoload 113;;;###autoload
114(defun put-image (image pos string &optional area) 114(defun put-image (image pos &optional string area)
115 "Put image IMAGE in front of POS in the current buffer. 115 "Put image IMAGE in front of POS in the current buffer.
116IMAGE must be an image created with `create-image' or `defimage'. 116IMAGE must be an image created with `create-image' or `defimage'.
117IMAGE is displayed by putting an overlay into the current buffer with a 117IMAGE is displayed by putting an overlay into the current buffer with a
118`before-string' STRING that has a `display' property whose value is the 118`before-string' STRING that has a `display' property whose value is the
119image. 119image. STRING is defaulted if you omit it.
120POS may be an integer or marker. 120POS may be an integer or marker.
121AREA is where to display the image. AREA nil or omitted means 121AREA is where to display the image. AREA nil or omitted means
122display it in the text area, a value of `left-margin' means 122display it in the text area, a value of `left-margin' means
123display it in the left marginal area, a value of `right-margin' 123display it in the left marginal area, a value of `right-margin'
124means display it in the right marginal area." 124means display it in the right marginal area."
125 (unless string (setq string "x"))
125 (let ((buffer (current-buffer))) 126 (let ((buffer (current-buffer)))
126 (unless (eq (car image) 'image) 127 (unless (eq (car-safe image) 'image)
127 (error "Not an image: %s" image)) 128 (error "Not an image: %s" image))
128 (unless (or (null area) (memq area '(left-margin right-margin))) 129 (unless (or (null area) (memq area '(left-margin right-margin)))
129 (error "Invalid area %s" area)) 130 (error "Invalid area %s" area))
@@ -136,15 +137,17 @@ means display it in the right marginal area."
136 137
137 138
138;;;###autoload 139;;;###autoload
139(defun insert-image (image string &optional area) 140(defun insert-image (image &optional string area)
140 "Insert IMAGE into current buffer at point. 141 "Insert IMAGE into current buffer at point.
141IMAGE is displayed by inserting STRING into the current buffer 142IMAGE is displayed by inserting STRING into the current buffer
142with a `display' property whose value is the image. 143with a `display' property whose value is the image. STRING is
144defaulted if you omit it.
143AREA is where to display the image. AREA nil or omitted means 145AREA is where to display the image. AREA nil or omitted means
144display it in the text area, a value of `left-margin' means 146display it in the text area, a value of `left-margin' means
145display it in the left marginal area, a value of `right-margin' 147display it in the left marginal area, a value of `right-margin'
146means display it in the right marginal area." 148means display it in the right marginal area."
147 (unless (eq (car image) 'image) 149 (unless string (setq string "x"))
150 (unless (eq (car-safe image) 'image)
148 (error "Not an image: %s" image)) 151 (error "Not an image: %s" image))
149 (unless (or (null area) (memq area '(left-margin right-margin))) 152 (unless (or (null area) (memq area '(left-margin right-margin)))
150 (error "Invalid area %s" area)) 153 (error "Invalid area %s" area))
@@ -179,17 +182,19 @@ BUFFER nil or omitted means use the current buffer."
179(defun find-image (specs) 182(defun find-image (specs)
180 "Find an image, choosing one of a list of image specifications. 183 "Find an image, choosing one of a list of image specifications.
181 184
182SPECS is a list of image specifications. DOC is an optional 185SPECS is a list of image specifications.
183documentation string.
184 186
185Each image specification in SPECS is a property list. The contents of 187Each image specification in SPECS is a property list. The contents of
186a specification are image type dependent. All specifications must at 188a specification are image type dependent. All specifications must at
187least contain the properties `:type TYPE' and either `:file FILE' or 189least contain the properties `:type TYPE' and either `:file FILE' or
188`:data DATA', where TYPE is a symbol specifying the image type, 190`:data DATA', where TYPE is a symbol specifying the image type,
189e.g. `xbm', FILE is the file to load the image from, and DATA is a 191e.g. `xbm', FILE is the file to load the image from, and DATA is a
190string containing the actual image data. The first image 192string containing the actual image data. The specification whose TYPE
191specification whose TYPE is supported, and FILE exists, is used to 193is supported, and FILE exists, is used to construct the image
192define SYMBOL." 194specification to be returned. Return nil if no specification is
195satisfied.
196
197The image is looked for first on `load-path' and then in `data-directory'."
193 (let (image) 198 (let (image)
194 (while (and specs (null image)) 199 (while (and specs (null image))
195 (let* ((spec (car specs)) 200 (let* ((spec (car specs))
@@ -206,8 +211,12 @@ define SYMBOL."
206 (setq found try-file))) 211 (setq found try-file)))
207 (setq path (cdr path))) 212 (setq path (cdr path)))
208 (unless found 213 (unless found
209 (setq found (expand-file-name file data-directory))) 214 (let ((try-file (expand-file-name file data-directory)))
210 (setq image (cons 'image (plist-put spec :file found))))) 215 (if (file-readable-p try-file)
216 (setq found try-file))))
217 (if found
218 (setq image
219 (cons 'image (plist-put spec :file found))))))
211 ((not (null data)) 220 ((not (null data))
212 (setq image (cons 'image spec))))) 221 (setq image (cons 'image spec)))))
213 (setq specs (cdr specs)))) 222 (setq specs (cdr specs))))