diff options
| author | Glenn Morris | 2012-10-22 20:46:11 -0400 |
|---|---|---|
| committer | Glenn Morris | 2012-10-22 20:46:11 -0400 |
| commit | ea1d4aaca0a593c99673912cee3ea910a958d38c (patch) | |
| tree | efadb758b3d03faa47349ec3512a44bd82f2eb0a | |
| parent | f961c7d82bb50cea1e6425042c79c26d23dbc2f1 (diff) | |
| download | emacs-ea1d4aaca0a593c99673912cee3ea910a958d38c.tar.gz emacs-ea1d4aaca0a593c99673912cee3ea910a958d38c.zip | |
image-type-from-file-name fix for bug#9045
* lisp/image.el (image-type-from-file-name): If multiple types match,
return the first one that is supported.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/image.el | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f1714548a98..5d527dcd330 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-10-23 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * image.el (image-type-from-file-name): If multiple types match, | ||
| 4 | return the first one that is supported. (Bug#9045) | ||
| 5 | |||
| 1 | 2012-10-22 Glenn Morris <rgm@gnu.org> | 6 | 2012-10-22 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * image.el (imagemagick-enabled-types): Doc fix. | 8 | * image.el (imagemagick-enabled-types): Doc fix. |
diff --git a/lisp/image.el b/lisp/image.el index 56c2fdff23f..aef44fc3701 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -308,8 +308,17 @@ be determined." | |||
| 308 | "Determine the type of image file FILE from its name. | 308 | "Determine the type of image file FILE from its name. |
| 309 | Value is a symbol specifying the image type, or nil if type cannot | 309 | Value is a symbol specifying the image type, or nil if type cannot |
| 310 | be determined." | 310 | be determined." |
| 311 | (assoc-default file image-type-file-name-regexps 'string-match-p)) | 311 | (let (type first) |
| 312 | 312 | (or | |
| 313 | (catch 'found | ||
| 314 | (dolist (elem image-type-file-name-regexps) | ||
| 315 | (when (string-match-p (car elem) file) | ||
| 316 | (setq type (cdr elem)) | ||
| 317 | (or first (setq first type)) | ||
| 318 | (if (image-type-available-p type) | ||
| 319 | (throw 'found type))))) | ||
| 320 | ;; If nothing seems to be supported, return the first type that matched. | ||
| 321 | first))) | ||
| 313 | 322 | ||
| 314 | ;;;###autoload | 323 | ;;;###autoload |
| 315 | (defun image-type (source &optional type data-p) | 324 | (defun image-type (source &optional type data-p) |