diff options
| author | Dave Love | 2000-06-06 14:27:42 +0000 |
|---|---|---|
| committer | Dave Love | 2000-06-06 14:27:42 +0000 |
| commit | cedbd8d02f7893a32ed841cc4819ae3924c1cd9b (patch) | |
| tree | 2265c1d7bf0406f592d6fda31bbd8931ccf48878 | |
| parent | a57a1605523357cfea72fc15a36c51e69321e83a (diff) | |
| download | emacs-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.el | 35 |
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. |
| 116 | IMAGE must be an image created with `create-image' or `defimage'. | 116 | IMAGE must be an image created with `create-image' or `defimage'. |
| 117 | IMAGE is displayed by putting an overlay into the current buffer with a | 117 | IMAGE 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 |
| 119 | image. | 119 | image. STRING is defaulted if you omit it. |
| 120 | POS may be an integer or marker. | 120 | POS may be an integer or marker. |
| 121 | AREA is where to display the image. AREA nil or omitted means | 121 | AREA is where to display the image. AREA nil or omitted means |
| 122 | display it in the text area, a value of `left-margin' means | 122 | display it in the text area, a value of `left-margin' means |
| 123 | display it in the left marginal area, a value of `right-margin' | 123 | display it in the left marginal area, a value of `right-margin' |
| 124 | means display it in the right marginal area." | 124 | means 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. |
| 141 | IMAGE is displayed by inserting STRING into the current buffer | 142 | IMAGE is displayed by inserting STRING into the current buffer |
| 142 | with a `display' property whose value is the image. | 143 | with a `display' property whose value is the image. STRING is |
| 144 | defaulted if you omit it. | ||
| 143 | AREA is where to display the image. AREA nil or omitted means | 145 | AREA is where to display the image. AREA nil or omitted means |
| 144 | display it in the text area, a value of `left-margin' means | 146 | display it in the text area, a value of `left-margin' means |
| 145 | display it in the left marginal area, a value of `right-margin' | 147 | display it in the left marginal area, a value of `right-margin' |
| 146 | means display it in the right marginal area." | 148 | means 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 | ||
| 182 | SPECS is a list of image specifications. DOC is an optional | 185 | SPECS is a list of image specifications. |
| 183 | documentation string. | ||
| 184 | 186 | ||
| 185 | Each image specification in SPECS is a property list. The contents of | 187 | Each image specification in SPECS is a property list. The contents of |
| 186 | a specification are image type dependent. All specifications must at | 188 | a specification are image type dependent. All specifications must at |
| 187 | least contain the properties `:type TYPE' and either `:file FILE' or | 189 | least 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, |
| 189 | e.g. `xbm', FILE is the file to load the image from, and DATA is a | 191 | e.g. `xbm', FILE is the file to load the image from, and DATA is a |
| 190 | string containing the actual image data. The first image | 192 | string containing the actual image data. The specification whose TYPE |
| 191 | specification whose TYPE is supported, and FILE exists, is used to | 193 | is supported, and FILE exists, is used to construct the image |
| 192 | define SYMBOL." | 194 | specification to be returned. Return nil if no specification is |
| 195 | satisfied. | ||
| 196 | |||
| 197 | The 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)))) |