GNU bug report logs - #9516
imagemagick-register-types and image-file-name-extensions

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Thu, 15 Sep 2011 18:56:01 UTC

Severity: normal

Tags: fixed

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9516 in the body.
You can then email your comments to 9516 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Thu, 15 Sep 2011 18:56:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 15 Sep 2011 18:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: imagemagick-register-types and image-file-name-extensions
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.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Fri, 16 Sep 2011 02:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
	image-file-name-extensions
Date: Thu, 15 Sep 2011 22:23:29 -0400
> +	       (extension-regexp (concat "\\." extension "\\'")))

You forgot a regexp-quote.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Fri, 16 Sep 2011 13:40:02 GMT) Full text and rfc822 format available.

Message #11 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
	image-file-name-extensions
Date: Fri, 16 Sep 2011 09:34:17 -0400
> I propose a fix that adds them to `image-file-name-extensions'
> in `imagemagick-register-types':

There's something I don't understand:
- why do we have both image-file-name-extensions and image-file-name-regexps?
- why doesn't image-file.el use image-type-file-name-regexps?


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Fri, 16 Sep 2011 20:14:02 GMT) Full text and rfc822 format available.

Message #14 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
	image-file-name-extensions
Date: Fri, 16 Sep 2011 17:09:49 +0300
>> I propose a fix that adds them to `image-file-name-extensions'
>> in `imagemagick-register-types':
>
> There's something I don't understand:
> - why do we have both image-file-name-extensions and image-file-name-regexps?

I guess for historical reasons.

> - why doesn't image-file.el use image-type-file-name-regexps?

It seems image-file.el is semi-obsoleted by image-mode.el,
so it should use more general settings from image-type-file-name-regexps.
And other packages should be fixed to use more general settings
from image.el instead of relying on definitions from image-file.el.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Fri, 23 Sep 2011 21:35:02 GMT) Full text and rfc822 format available.

Message #17 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9516 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9516: imagemagick-register-types and
	image-file-name-extensions
Date: Fri, 23 Sep 2011 17:34:07 -0400
Juri Linkov <juri <at> jurta.org> writes:

> It seems image-file.el is semi-obsoleted by image-mode.el,
> so it should use more general settings from image-type-file-name-regexps.
> And other packages should be fixed to use more general settings
> from image.el instead of relying on definitions from image-file.el.

Sounds right, though I think that can wait till post-release.

Please go ahead and commit your patch (with the regexp-quote).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Fri, 23 Sep 2011 21:42:02 GMT) Full text and rfc822 format available.

Message #20 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
	image-file-name-extensions
Date: Fri, 23 Sep 2011 17:40:53 -0400
Chong Yidong <cyd <at> stupidchicken.com> writes:

> Please go ahead and commit your patch (with the regexp-quote).

On second thought, there is a problem---image-file-name-extensions is a
defcustom, so your patch would trigger a "changed outside customize"
warning if the user tries customizing it after calling
imagemagick-register-types.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Sun, 25 Sep 2011 14:16:02 GMT) Full text and rfc822 format available.

Message #23 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
	image-file-name-extensions
Date: Sun, 25 Sep 2011 17:03:21 +0300
>> Please go ahead and commit your patch (with the regexp-quote).
>
> On second thought, there is a problem---image-file-name-extensions is a
> defcustom, so your patch would trigger a "changed outside customize"
> warning if the user tries customizing it after calling
> imagemagick-register-types.

Then we could change the function `image-file-name-regexp'
that dynamically constructs a composite regexp from
`image-file-name-extensions' and `image-file-name-regexps'.
What we could do is to add to its return value a regexp added
in `imagemagick-register-types' to `image-type-file-name-regexps'
with the assoc value `imagemagick':

=== modified file 'lisp/image-file.el'
--- lisp/image-file.el	2011-01-25 04:08:28 +0000
+++ lisp/image-file.el	2011-09-25 14:01:31 +0000
@@ -85,13 +85,12 @@ (defun image-file-name-regexp ()
 					 image-file-name-extensions)
 				  t)
 		      "\\'"))))
-    (if image-file-name-regexps
-	(mapconcat 'identity
-		   (if exts-regexp
-		       (cons exts-regexp image-file-name-regexps)
-		     image-file-name-regexps)
-		   "\\|")
-      exts-regexp)))
+    (mapconcat
+     'identity
+     (delq nil (list exts-regexp
+		     image-file-name-regexps
+		     (car (rassq 'imagemagick image-type-file-name-regexps))))
+     "\\|")))

This is a temporary solution for the next release of 24.1 that
will allow image-dired.el to display Imagemagick supported images.

I think in 24.2, defcustoms in image-file.el should be deprecated
and packages should use `image-type-file-name-regexps' instead.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Wed, 25 Sep 2019 12:32:01 GMT) Full text and rfc822 format available.

Message #26 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9516 <at> debbugs.gnu.org, Chong Yidong <cyd <at> stupidchicken.com>
Subject: Re: bug#9516: imagemagick-register-types and
 image-file-name-extensions
Date: Wed, 25 Sep 2019 14:30:59 +0200
Juri Linkov <juri <at> jurta.org> writes:

> Then we could change the function `image-file-name-regexp'
> that dynamically constructs a composite regexp from
> `image-file-name-extensions' and `image-file-name-regexps'.
> What we could do is to add to its return value a regexp added
> in `imagemagick-register-types' to `image-type-file-name-regexps'
> with the assoc value `imagemagick':

[...]

> +    (mapconcat
> +     'identity
> +     (delq nil (list exts-regexp
> +		     image-file-name-regexps
> +		     (car (rassq 'imagemagick image-type-file-name-regexps))))
> +     "\\|")))
>
> This is a temporary solution for the next release of 24.1 that
> will allow image-dired.el to display Imagemagick supported images.
>
> I think in 24.2, defcustoms in image-file.el should be deprecated
> and packages should use `image-type-file-name-regexps' instead.

This was seven years ago, but the patch wasn't applied.  I know that
ImageMagick is slightly semi-deprecated now, but I think this patch
possibly makes sense anyway.

I don't use the Dired thumbnail stuff, though.  Did anybody have an
objection to this that didn't land in the bug tracker?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Wed, 25 Sep 2019 20:32:02 GMT) Full text and rfc822 format available.

Message #29 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
 image-file-name-extensions
Date: Wed, 25 Sep 2019 22:57:07 +0300
>> Then we could change the function `image-file-name-regexp'
>> that dynamically constructs a composite regexp from
>> `image-file-name-extensions' and `image-file-name-regexps'.
>> What we could do is to add to its return value a regexp added
>> in `imagemagick-register-types' to `image-type-file-name-regexps'
>> with the assoc value `imagemagick':
>
> [...]
>
>> +    (mapconcat
>> +     'identity
>> +     (delq nil (list exts-regexp
>> +		     image-file-name-regexps
>> +		     (car (rassq 'imagemagick image-type-file-name-regexps))))
>> +     "\\|")))
>>
>> This is a temporary solution for the next release of 24.1 that
>> will allow image-dired.el to display Imagemagick supported images.
>>
>> I think in 24.2, defcustoms in image-file.el should be deprecated
>> and packages should use `image-type-file-name-regexps' instead.
>
> This was seven years ago, but the patch wasn't applied.  I know that
> ImageMagick is slightly semi-deprecated now, but I think this patch
> possibly makes sense anyway.

There was no hurry in installing this because all widely used formats
are already presented in image-type-file-name-regexps.

> I don't use the Dired thumbnail stuff, though.  Did anybody have an
> objection to this that didn't land in the bug tracker?

Sorry, I can't confirm if the patch still works since I don't remember
how I tested it long ago, so not sure if this change might break something.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9516; Package emacs. (Thu, 26 Sep 2019 19:28:01 GMT) Full text and rfc822 format available.

Message #32 received at 9516 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9516 <at> debbugs.gnu.org
Subject: Re: bug#9516: imagemagick-register-types and
 image-file-name-extensions
Date: Thu, 26 Sep 2019 21:27:14 +0200
Juri Linkov <juri <at> jurta.org> writes:

>> I don't use the Dired thumbnail stuff, though.  Did anybody have an
>> objection to this that didn't land in the bug tracker?
>
> Sorry, I can't confirm if the patch still works since I don't remember
> how I tested it long ago, so not sure if this change might break something.

I've now done some light testing in an ImageMagick-enabled Emacs, and it
seems to work fine, so I've pushed the patch.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 26 Sep 2019 19:28:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 9516 <at> debbugs.gnu.org and Juri Linkov <juri <at> jurta.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 26 Sep 2019 19:28:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 25 Oct 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 296 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.