GNU bug report logs - #24317
25.1.50; image-dired-rotate-original: regexp doesn't match .jpeg suffix

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Sat, 27 Aug 2016 08:05:01 UTC

Severity: minor

Found in version 25.1.50

Done: Tino Calancha <tino.calancha <at> gmail.com>

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 24317 in the body.
You can then email your comments to 24317 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 bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 08:05:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tino Calancha <tino.calancha <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 27 Aug 2016 08:05:01 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; image-dired-rotate-original: regexp doesn't match .jpeg
 suffix
Date: Sat, 27 Aug 2016 17:04:01 +0900 (JST)
emacs -Q:

;; file: full name of a .jpeg file in your filesystem
(let ((file "/tmp/bug24317.jpeg"))
  (require 'dired)
  (require 'image-dired)
  (dired file)
  (image-dired-display-thumbs)
  (image-dired-rotate-original 90))
;; if: Only JPEG images can be rotated!


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 4ea0333150937d3f2f615df1ed476e6279caf77b Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sat, 27 Aug 2016 16:53:37 +0900
Subject: [PATCH] image-dired-rotate-original: regexp doesn't match .jpeg
 suffix

* lisp/image-dired.el (image-dired-jpeg-suffix-regexp): New defvar.
(image-dired-rotate-original, image-dired-get-exif-file-name):
Use it (Bug#24317).
---
 lisp/image-dired.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 67b023d..bb43a55 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1906,13 +1906,16 @@ image-dired-refresh-thumb
     (clear-image-cache)
     (image-dired-create-thumb file (image-dired-thumb-name file))))

+(defvar image-dired-jpeg-suffix-regexp "\\.[Jj][Pp][Ee]?[Gg]$"
+  "Regexp to match JPEG file extensions.")
+
 (defun image-dired-rotate-original (degrees)
   "Rotate original image DEGREES degrees."
   (if (not (image-dired-image-at-point-p))
       (message "No image at point")
     (let ((file (image-dired-original-file-name))
           command)
-      (if (not (string-match "\\.[jJ][pP[eE]?[gG]$" file))
+      (if (not (string-match image-dired-jpeg-suffix-regexp file))
           (error "Only JPEG images can be rotated!"))
       (setq command (format-spec
                      image-dired-cmd-rotate-original-options
@@ -1952,7 +1955,8 @@ image-dired-get-exif-file-name
 YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg.  Used from
 `image-dired-copy-with-exif-file-name'."
   (let (data no-exif-data-found)
-    (if (not (string-match "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name 
file)))
+    (if (not (string-match image-dired-jpeg-suffix-regexp
+                           (expand-file-name file)))
         (progn
           (setq no-exif-data-found t)
           (setq data
-- 
2.9.3


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.9)
 of 2016-08-26 built on calancha-pc
Repository revision: 1c7166a3ba399efbefc65feb8a6a41ef0dfa33a4





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 08:21:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24317 <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50;
 image-dired-rotate-original: regexp doesn't match .jpeg suffix
Date: Sat, 27 Aug 2016 11:21:10 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sat, 27 Aug 2016 17:04:01 +0900 (JST)
> 
> >From 4ea0333150937d3f2f615df1ed476e6279caf77b Mon Sep 17 00:00:00 2001
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sat, 27 Aug 2016 16:53:37 +0900
> Subject: [PATCH] image-dired-rotate-original: regexp doesn't match .jpeg
>   suffix
> 
> * lisp/image-dired.el (image-dired-jpeg-suffix-regexp): New defvar.
> (image-dired-rotate-original, image-dired-get-exif-file-name):
> Use it (Bug#24317).

I understand why we need to fix a typo in the regexp (which the log
entry doesn't even mention, btw), but what's the rationale for making
it a defvar?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 08:54:01 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24317 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sat, 27 Aug 2016 17:53:49 +0900 (JST)

> I understand why we need to fix a typo in the regexp (which the log
> entry doesn't even mention, btw), but what's the rationale for making
> it a defvar?
I made a defvar because it was used in 2 functions: only one show the 
typo.
Do you prefer just the simple 1-line fix? (ie., just correct the typo)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 08:58:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24317 <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sat, 27 Aug 2016 11:57:47 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sat, 27 Aug 2016 17:53:49 +0900 (JST)
> cc: Tino Calancha <tino.calancha <at> gmail.com>, 24317 <at> debbugs.gnu.org
> 
> > I understand why we need to fix a typo in the regexp (which the log
> > entry doesn't even mention, btw), but what's the rationale for making
> > it a defvar?
> I made a defvar because it was used in 2 functions: only one show the 
> typo.

In that case, why not make a function that does the string-match as
well, in which case you won't need a variable, because it will appear
in a single place, and will also have the test localized to a single
function?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 09:22:02 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24317 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sat, 27 Aug 2016 18:21:25 +0900 (JST)

> In that case, why not make a function that does the string-match as
> well, in which case you won't need a variable, because it will appear
> in a single place, and will also have the test localized to a single
> function?
>
> Thanks.
I see.  Its good idea.
I have choose a defsubst because it is small function.  I am not sure
if it is recommended or if people prefers always defun's.
Please, et me know if the doc string reads weird and need some tunning

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 0be47e3968d898bf8f44e5c37f9035be3147a4a2 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sat, 27 Aug 2016 18:16:25 +0900
Subject: [PATCH] image-dired-rotate-original: Fix regexp typo

* lisp/image-dired.el (image-dired-jpeg-file-p): New defsubst;
Return non-nil if a file has a JPEG extension.
(image-dired-rotate-original, image-dired-get-exif-file-name):
Use it (Bug#24317).
---
 lisp/image-dired.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 67b023d..7c8d43b 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1205,6 +1205,10 @@ image-dired-dired-file-marked-p
     (beginning-of-line)
     (not (looking-at "^ .*$"))))

+(defsubst image-dired-jpeg-file-p (file)
+  "Return non-nil if FILE has a JPEG extension."
+  (string-match-p "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name file)))
+
 (defun image-dired-modify-mark-on-thumb-original-file (command)
   "Modify mark in dired buffer.
 COMMAND is one of `mark' for marking file in dired, `unmark' for
@@ -1912,7 +1916,7 @@ image-dired-rotate-original
       (message "No image at point")
     (let ((file (image-dired-original-file-name))
           command)
-      (if (not (string-match "\\.[jJ][pP[eE]?[gG]$" file))
+      (if (not (image-dired-jpeg-file-p file))
           (error "Only JPEG images can be rotated!"))
       (setq command (format-spec
                      image-dired-cmd-rotate-original-options
@@ -1952,7 +1956,7 @@ image-dired-get-exif-file-name
 YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg.  Used from
 `image-dired-copy-with-exif-file-name'."
   (let (data no-exif-data-found)
-    (if (not (string-match "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name 
file)))
+    (if (not (image-dired-jpeg-file-p file)))
         (progn
           (setq no-exif-data-found t)
           (setq data
-- 
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 09:28:02 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 24317 <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sat, 27 Aug 2016 18:27:30 +0900 (JST)

On Sat, 27 Aug 2016, Tino Calancha wrote:

> -    (if (not (string-match "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name file)))
> +    (if (not (image-dired-jpeg-file-p file)))
I added one extra paren, it should read of course:
-    (if (not (string-match "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name file)))
+    (if (not (image-dired-jpeg-file-p file))
Sorry for that.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 09:52:01 GMT) Full text and rfc822 format available.

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

From: Thien-Thi Nguyen <ttn <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 24317 <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50;
 image-dired-rotate-original: regexp doesn't match .jpeg suffix
Date: Sat, 27 Aug 2016 11:42:31 +0200
[Message part 1 (text/plain, inline)]
() Tino Calancha <tino.calancha <at> gmail.com>
() Sat, 27 Aug 2016 18:21:25 +0900 (JST)

   I see.  Its good idea.

Another idea is to use function ‘image-type’,
which can handle a filename as its SOURCE argument.

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (type via)
   (case type
     (technical (eq 'mailing-list via))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 11:29:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thien-Thi Nguyen <ttn <at> gnu.org>
Cc: 24317 <at> debbugs.gnu.org, tino.calancha <at> gmail.com
Subject: Re: bug#24317: 25.1.50;
 image-dired-rotate-original: regexp doesn't match .jpeg suffix
Date: Sat, 27 Aug 2016 14:28:20 +0300
> From: Thien-Thi Nguyen <ttn <at> gnu.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  24317 <at> debbugs.gnu.org
> Date: Sat, 27 Aug 2016 11:42:31 +0200
> 
> Another idea is to use function ‘image-type’,
> which can handle a filename as its SOURCE argument.

That is better, yes.  Except that

  (let ((case-fold-search)) (image-type-from-file-name "foo.JPEG"))
    => nil

So I guess that function needs a minor change to be more robust.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 12:19:01 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Thien-Thi Nguyen <ttn <at> gnu.org>, 24317 <at> debbugs.gnu.org,
 tino.calancha <at> gmail.com
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sat, 27 Aug 2016 21:18:37 +0900 (JST)
[Message part 1 (text/plain, inline)]

On Sat, 27 Aug 2016, Eli Zaretskii wrote:

>> From: Thien-Thi Nguyen <ttn <at> gnu.org>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,  24317 <at> debbugs.gnu.org
>> Date: Sat, 27 Aug 2016 11:42:31 +0200
>>
>> Another idea is to use function ‘image-type’,
>> which can handle a filename as its SOURCE argument.
>
> That is better, yes.  Except that
>
>  (let ((case-fold-search)) (image-type-from-file-name "foo.JPEG"))
>    => nil
>
> So I guess that function needs a minor change to be more robust.
That's right.  It wuld be worth take a look on 
'image-type-from-file-name'.

I have corrected previous patch.  I drop expand-file-name from
'image-dired-jpeg-file-p'.  I also corrected the extra paren mentioned
before.
If people is happy with it i will apply this patch.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 9d95e361e45df393feaf3f6c451878e794c924eb Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sat, 27 Aug 2016 18:41:44 +0900
Subject: [PATCH] image-dired-rotate-original: Fix regexp typo

* lisp/image-dired.el (image-dired-jpeg-file-p): New defsubst;
Return non-nil if a file has a JPEG extension.
(image-dired-rotate-original, image-dired-get-exif-file-name):
Use it (Bug#24317).
---
 lisp/image-dired.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 67b023d..61b0751 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1205,6 +1205,10 @@ image-dired-dired-file-marked-p
     (beginning-of-line)
     (not (looking-at "^ .*$"))))

+(defsubst image-dired-jpeg-file-p (file)
+  "Return non-nil if FILE has a JPEG extension."
+  (string-match-p "\\.[Jj][Pp][Ee]?[Gg]$" file))
+
 (defun image-dired-modify-mark-on-thumb-original-file (command)
   "Modify mark in dired buffer.
 COMMAND is one of `mark' for marking file in dired, `unmark' for
@@ -1912,7 +1916,7 @@ image-dired-rotate-original
       (message "No image at point")
     (let ((file (image-dired-original-file-name))
           command)
-      (if (not (string-match "\\.[jJ][pP[eE]?[gG]$" file))
+      (if (not (image-dired-jpeg-file-p file))
           (error "Only JPEG images can be rotated!"))
       (setq command (format-spec
                      image-dired-cmd-rotate-original-options
@@ -1952,7 +1956,7 @@ image-dired-get-exif-file-name
 YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg.  Used from
 `image-dired-copy-with-exif-file-name'."
   (let (data no-exif-data-found)
-    (if (not (string-match "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name 
file)))
+    (if (not (image-dired-jpeg-file-p (expand-file-name file)))
         (progn
           (setq no-exif-data-found t)
           (setq data
-- 
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sat, 27 Aug 2016 12:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: ttn <at> gnu.org, 24317 <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sat, 27 Aug 2016 15:55:22 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sat, 27 Aug 2016 21:18:37 +0900 (JST)
> cc: Thien-Thi Nguyen <ttn <at> gnu.org>, tino.calancha <at> gmail.com, 
>     24317 <at> debbugs.gnu.org
> 
> > That is better, yes.  Except that
> >
> >  (let ((case-fold-search)) (image-type-from-file-name "foo.JPEG"))
> >    => nil
> >
> > So I guess that function needs a minor change to be more robust.
> That's right.  It wuld be worth take a look on 
> 'image-type-from-file-name'.
> 
> I have corrected previous patch.  I drop expand-file-name from
> 'image-dired-jpeg-file-p'.  I also corrected the extra paren mentioned
> before.
> If people is happy with it i will apply this patch.

I think we should indeed use image-type instead of having yet another
function that recognizes JPEG.  The problem I pointed out should be
fixed in image-type-from-file-name, regardless.

Sorry this wasn't clear enough from what I wrote before.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sun, 28 Aug 2016 06:23:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: Thien-Thi Nguyen <ttn <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org>,
 24317 <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50;
 image-dired-rotate-original: regexp doesn't match .jpeg suffix
Date: Sun, 28 Aug 2016 08:22:32 +0200
On Aug 27 2016, Tino Calancha <tino.calancha <at> gmail.com> wrote:

> diff --git a/lisp/image-dired.el b/lisp/image-dired.el
> index 67b023d..61b0751 100644
> --- a/lisp/image-dired.el
> +++ b/lisp/image-dired.el
> @@ -1205,6 +1205,10 @@ image-dired-dired-file-marked-p
>       (beginning-of-line)
>       (not (looking-at "^ .*$"))))
>
> +(defsubst image-dired-jpeg-file-p (file)
> +  "Return non-nil if FILE has a JPEG extension."
> +  (string-match-p "\\.[Jj][Pp][Ee]?[Gg]$" file))

FWIW, the regexp should end in "\\'".

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sun, 28 Aug 2016 12:27:02 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ttn <at> gnu.org, 24317 <at> debbugs.gnu.org, schwab <at> linux-m68k.org,
 Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sun, 28 Aug 2016 21:26:23 +0900 (JST)

On Sat, 27 Aug 2016, Eli Zaretskii wrote:

> I think we should indeed use image-type instead of having yet another
> function that recognizes JPEG.  The problem I pointed out should be
> fixed in image-type-from-file-name, regardless.
I see.  I have prepared following new patch:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From b953d600a295e4e0aa58b85126296663e7f02472 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sun, 28 Aug 2016 21:20:22 +0900
Subject: [PATCH] image-type-from-file-name: Perform a case insensitive 
match

Fix Bug#24317
* lisp/image.el (image-type-from-file-name): Bind case-fold-search
to a non-nil value to force a case insensitive match.
* lisp/image-dired.el (image-dired-rotate-original):
Use image-type (Bug#24317).
(image-dired-get-exif-file-name): Idem.
Set 'no-exif-data-found' and 'data' in same setq call.
Use file-attribute-modification-time.
---
 lisp/image-dired.el | 19 +++++++++----------
 lisp/image.el       |  2 +-
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 67b023d..34e4eae 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1912,8 +1912,8 @@ image-dired-rotate-original
       (message "No image at point")
     (let ((file (image-dired-original-file-name))
           command)
-      (if (not (string-match "\\.[jJ][pP[eE]?[gG]$" file))
-          (error "Only JPEG images can be rotated!"))
+      (unless (eq 'jpeg (image-type file))
+        (error "Only JPEG images can be rotated!"))
       (setq command (format-spec
                      image-dired-cmd-rotate-original-options
                      (list
@@ -1952,15 +1952,14 @@ image-dired-get-exif-file-name
 YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg.  Used from
 `image-dired-copy-with-exif-file-name'."
   (let (data no-exif-data-found)
-    (if (not (string-match "\\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name 
file)))
-        (progn
-          (setq no-exif-data-found t)
-          (setq data
-                (format-time-string
-                 "%Y:%m:%d %H:%M:%S"
-                 (nth 5 (file-attributes (expand-file-name file))))))
+    (if (not (eq 'jpeg (image-type (expand-file-name file))))
+        (setq no-exif-data-found t
+              data (format-time-string
+                    "%Y:%m:%d %H:%M:%S"
+                    (file-attribute-modification-time
+                     (file-attributes (expand-file-name file)))))
       (setq data (image-dired-get-exif-data (expand-file-name file)
-				      "DateTimeOriginal")))
+                                            "DateTimeOriginal")))
     (while (string-match "[ :]" data)
       (setq data (replace-match "_" nil nil data)))
     (format "%s%s%s" data
diff --git a/lisp/image.el b/lisp/image.el
index 272cee5..d1cdc44 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -343,7 +343,7 @@ image-type-from-file-name
   "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."
-  (let (type first)
+  (let (type first (case-fold-search t))
     (catch 'found
       (dolist (elem image-type-file-name-regexps first)
 	(when (string-match-p (car elem) file)
-- 
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.9)
 of 2016-08-27
Repository revision: 7fcce24e75b8281621a0b8816dc58cbdc05fdc91






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sun, 28 Aug 2016 14:32:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: ttn <at> gnu.org, 24317 <at> debbugs.gnu.org, schwab <at> linux-m68k.org
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sun, 28 Aug 2016 17:31:22 +0300
> > I think we should indeed use image-type instead of having yet another
> > function that recognizes JPEG.  The problem I pointed out should be
> > fixed in image-type-from-file-name, regardless.
> I see.  I have prepared following new patch:
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> >From b953d600a295e4e0aa58b85126296663e7f02472 Mon Sep 17 00:00:00 2001
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sun, 28 Aug 2016 21:20:22 +0900
> Subject: [PATCH] image-type-from-file-name: Perform a case insensitive 
> match
> 
> Fix Bug#24317
> * lisp/image.el (image-type-from-file-name): Bind case-fold-search
> to a non-nil value to force a case insensitive match.
> * lisp/image-dired.el (image-dired-rotate-original):
> Use image-type (Bug#24317).
> (image-dired-get-exif-file-name): Idem.
> Set 'no-exif-data-found' and 'data' in same setq call.
> Use file-attribute-modification-time.

Thanks, this looks good to me.  Please push in a few days if no
additional comments are posted.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24317; Package emacs. (Sun, 28 Aug 2016 14:50:01 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ttn <at> gnu.org, 24317 <at> debbugs.gnu.org, schwab <at> linux-m68k.org,
 Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sun, 28 Aug 2016 23:49:17 +0900 (JST)

On Sun, 28 Aug 2016, Eli Zaretskii wrote:

> Thanks, this looks good to me.  Please push in a few days if no
> additional comments are posted.
Thank you very much Eli.  I promise I will be patient :-)





Reply sent to Tino Calancha <tino.calancha <at> gmail.com>:
You have taken responsibility. (Sun, 04 Sep 2016 02:20:02 GMT) Full text and rfc822 format available.

Notification sent to Tino Calancha <tino.calancha <at> gmail.com>:
bug acknowledged by developer. (Sun, 04 Sep 2016 02:20:02 GMT) Full text and rfc822 format available.

Message #49 received at 24317-done <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 24317-done <at> debbugs.gnu.org
Subject: Re: bug#24317: 25.1.50; image-dired-rotate-original: regexp doesn't
 match .jpeg suffix
Date: Sun, 4 Sep 2016 11:19:01 +0900 (JST)

On Sun, 28 Aug 2016, Eli Zaretskii wrote:

> Thanks, this looks good to me.  Please push in a few days if no
> additional comments are posted.

Fixed in master branch.




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

This bug report was last modified 8 years and 260 days ago.

Previous Next


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