]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `n'/`p' in image-mode also find externally converted images
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 3 Aug 2020 07:14:52 +0000 (09:14 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 3 Aug 2020 07:14:52 +0000 (09:14 +0200)
* lisp/image-file.el (image-file-name-regexp): Use it to make
`n'/`p' in image mode work (bug#39994).

* lisp/image/image-converter.el
(image-converter-file-name-extensions): New variable to keep track
of all suffixes.
(image-convert-p): Update.
(image-converter--find-converter): Set.

lisp/image-file.el
lisp/image/image-converter.el

index 89cd75d50dd04d0868660812616e4146060555b8..22366c89e6ab57701748c089b68f4bce0adca2ca 100644 (file)
@@ -32,6 +32,7 @@
 ;;; Code:
 
 (require 'image)
+(require 'image-converter)
 
 
 ;;;###autoload
@@ -80,10 +81,13 @@ the variable is set using \\[customize]."
   (let ((exts-regexp
         (and image-file-name-extensions
              (concat "\\."
-                     (regexp-opt (nconc (mapcar #'upcase
-                                                image-file-name-extensions)
-                                        image-file-name-extensions)
-                                 t)
+                     (regexp-opt
+                       (append (mapcar #'upcase image-file-name-extensions)
+                              image-file-name-extensions
+                               (mapcar #'upcase
+                                      image-converter-file-name-extensions)
+                               image-converter-file-name-extensions)
+                      t)
                      "\\'"))))
     (mapconcat
      'identity
index b694052f5b9fed520b8aaf7c0d176eceff318cb5..ee1dc845fb5bbe1a70c217b6a5f6925cef668b01 100644 (file)
@@ -42,6 +42,9 @@ installed on the system."
 (defvar image-converter-regexp nil
   "A regexp that matches the file name suffixes that can be converted.")
 
+(defvar image-converter-file-name-extensions nil
+  "A list of file name suffixes that can be converted.")
+
 (defvar image-converter--converters
   '((graphicsmagick :command ("gm" "convert") :probe ("-list" "format"))
     (ffmpeg :command "ffmpeg" :probe "-decoders")
@@ -58,9 +61,11 @@ is a string, it should be a MIME format string like
   (unless image-converter
     (image-converter--find-converter))
   ;; When image-converter was customized
-  (if (and image-converter (not image-converter-regexp))
-      (when-let ((formats (image-converter--probe image-converter)))
-        (setq image-converter-regexp (concat "\\." (regexp-opt formats) "\\'"))))
+  (when (and image-converter (not image-converter-regexp))
+    (when-let ((formats (image-converter--probe image-converter)))
+      (setq image-converter-regexp
+            (concat "\\." (regexp-opt formats) "\\'"))
+      (setq image-converter-file-name-extensions formats)))
   (and image-converter
        (or (and (not data-p)
                 (string-match image-converter-regexp source))
@@ -183,7 +188,8 @@ data is returned as a string."
     (dolist (elem image-converter--converters)
       (when-let ((formats (image-converter--probe (car elem))))
         (setq image-converter (car elem)
-              image-converter-regexp (concat "\\." (regexp-opt formats) "\\'"))
+              image-converter-regexp (concat "\\." (regexp-opt formats) "\\'")
+              image-converter-file-name-extensions formats)
         (throw 'done image-converter)))))
 
 (cl-defmethod image-converter--convert ((type (eql graphicsmagick)) source