Subject: imagemagick-register-types and image-file-name-extensions

From: Juri Linkov <[email-masked]>
Date: Thu, 15 Sep 2011 21:34:10 +0300

In Dired typing `C-t C-t' (`image-dired-dired-toggle-marked-thumbs')
doesn't show images supported by ImageMagick.

It gets file extensions of supported image types by calling the function
`image-file-name-regexp' and it gets them from the variable
`image-file-name-extensions' that currently misses file extensions
supported by ImageMagick.

I propose a fix that adds them to `image-file-name-extensions'
in `imagemagick-register-types':

=== modified file 'lisp/image.el'
--- lisp/image.el	2011-07-25 08:23:29 +0000
+++ lisp/image.el	2011-09-15 18:32:51 +0000
@@ -699,11 +699,11 @@ (defun imagemagick-register-types ()
       (dolist (im-inhibit imagemagick-types-inhibit)
 	(setq im-types (delq im-inhibit im-types)))
       (dolist (im-type im-types)
-	(let ((extension
-	       (concat "\\." (downcase (symbol-name im-type))
-		       "\\'")))
-	  (push (cons extension 'image-mode) auto-mode-alist)
-	  (push (cons extension 'imagemagick)
+	(let* ((extension (downcase (symbol-name im-type)))
+	       (extension-regexp (concat "\\." extension "\\'")))
+	  (push extension image-file-name-extensions)
+	  (push (cons extension-regexp 'image-mode) auto-mode-alist)
+	  (push (cons extension-regexp 'imagemagick)
 		image-type-file-name-regexps))))))

There are other packages that rely on image file extensions
defined in image-file.el:

./iimage.el:61:				     image-file-name-extensions)
./iimage.el:62:			     image-file-name-extensions)
./image-dired.el:548:  (unless (string-match (image-file-name-regexp) file)
./image-dired.el:656:     (when (and image-file (string-match-p (image-file-name-regexp) image-file))
./image-dired.el:867:  (dired-mark-files-regexp (image-file-name-regexp))
./org/org.el:19319:  (if (and (not extensions) (fboundp 'image-file-name-regexp))
./org/org.el:19320:      (image-file-name-regexp)
./org/org.el:19321:    (let ((image-file-name-extensions
./org/org.el:19327:					 image-file-name-extensions)
./org/org.el:19328:				 image-file-name-extensions)
./thumbs.el:228:	    (directory-files (thumbs-thumbsdir) t (image-file-name-regexp)))
./thumbs.el:411:   (directory-files dir t (or reg (image-file-name-regexp)))

I suppose all they will benefit from this fix as well.