emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110621: image-type-from-file-name fi


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110621: image-type-from-file-name fix for bug#9045
Date: Mon, 22 Oct 2012 20:46:11 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110621
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Mon 2012-10-22 20:46:11 -0400
message:
  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.
modified:
  lisp/ChangeLog
  lisp/image.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-10-22 21:53:03 +0000
+++ b/lisp/ChangeLog    2012-10-23 00:46:11 +0000
@@ -1,3 +1,8 @@
+2012-10-23  Glenn Morris  <address@hidden>
+
+       * image.el (image-type-from-file-name): If multiple types match,
+       return the first one that is supported.  (Bug#9045)
+
 2012-10-22  Glenn Morris  <address@hidden>
 
        * image.el (imagemagick-enabled-types): Doc fix.

=== modified file 'lisp/image.el'
--- a/lisp/image.el     2012-10-22 21:53:03 +0000
+++ b/lisp/image.el     2012-10-23 00:46:11 +0000
@@ -308,8 +308,17 @@
   "Determine the type of image file FILE from its name.
 Value is a symbol specifying the image type, or nil if type cannot
 be determined."
-  (assoc-default file image-type-file-name-regexps 'string-match-p))
-
+  (let (type first)
+    (or
+     (catch 'found
+       (dolist (elem image-type-file-name-regexps)
+        (when (string-match-p (car elem) file)
+          (setq type (cdr elem))
+          (or first (setq first type))
+          (if (image-type-available-p type)
+              (throw 'found type)))))
+     ;; If nothing seems to be supported, return the first type that matched.
+     first)))
 
 ;;;###autoload
 (defun image-type (source &optional type data-p)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]