From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mathias Dahl Newsgroups: gmane.emacs.devel Subject: Re: image-dired: Check all external programs available Date: Tue, 30 Aug 2016 14:11:43 +0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1140f5587fb89b053b48e3f4 X-Trace: blaine.gmane.org 1472559188 27492 195.159.176.226 (30 Aug 2016 12:13:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Aug 2016 12:13:08 +0000 (UTC) Cc: Emacs developers To: Tino Calancha Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 30 14:13:03 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1behuY-0006Yp-Lm for ged-emacs-devel@m.gmane.org; Tue, 30 Aug 2016 14:13:03 +0200 Original-Received: from localhost ([::1]:48816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1behuW-0006Qp-Cm for ged-emacs-devel@m.gmane.org; Tue, 30 Aug 2016 08:13:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1behth-0006Ph-Md for emacs-devel@gnu.org; Tue, 30 Aug 2016 08:12:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1behtd-00058M-68 for emacs-devel@gnu.org; Tue, 30 Aug 2016 08:12:08 -0400 Original-Received: from mail-ua0-x231.google.com ([2607:f8b0:400c:c08::231]:36557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1behtc-000584-To for emacs-devel@gnu.org; Tue, 30 Aug 2016 08:12:05 -0400 Original-Received: by mail-ua0-x231.google.com with SMTP id m60so28488781uam.3 for ; Tue, 30 Aug 2016 05:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5T2DudiXUx/+wOArLJ7C+9IitRX7GpCzYbC9LD2WNpU=; b=unnlBnj/4e50eVGnqaCkNX/7ltW8f/i9or8uQGPu0RdeGg/JrbBsRpJ8gyKG6C/lnm XamL0mQ76Wx6n9bDcTnZh6H4p6Ir7XK7Nt6EHrd1c/CtWH6xqawGTcKCTv/DxIEN0y6B FgePzHv4TBonKPJ2kfhPfLcErSkoN41uPS4kmzzNK7UoZ5hZb3+ZHDuWCOb7wGZ8Gb6l jz7K0jEwwRtrgy1mrqvkAX8KLOjw2Gmf0nVGVnnRAPhhnIrCUFaSt87nAMRJVtqhUNCE cnC6PgkVdToLH7h/y+Eh7Yzrd/DnmePB7rdi57O4UsfZeRmSL3JaSb/4oWyPcN9ArwHz i4vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5T2DudiXUx/+wOArLJ7C+9IitRX7GpCzYbC9LD2WNpU=; b=Yf+GnswJB/OzP8uCaCxN5RXsgW0BKHiEsXPqkEwcFzJGaoQZUFAafs0CdQmYgP3BB2 EunEXTYlz/71rw1h/AF4+TGWR1wxC/fDjePQQrJOPPr+r1kCHgESm10g0aCUTnSk8pLk nrG32D4p183SuXkk02CfAhRi2ywl5KR1Ern84A01T3puHTwnqpPNH7dkqJTIgsF15qGB SgPlNc+Bk+VevCoCXCQq2O42iLpyRKm3pMC4P+zIrMEowhXAacXYgeGb9b1lhkq6MFBs FJkYTd46O81Xu2E5xr4a4r/DQ988i9RbFhrQCsh63E1H2Oe0pQxabhZ526SAG5GA5CEm 5zqw== X-Gm-Message-State: AE9vXwNO46kuYqmKoCZrzBy+BQzGtp7T1jcnYRxLkTcLx3o+FaL2gRKDUQ7AtMa8ThpSg3qN9bqCV6xBmVez7Q== X-Received: by 10.31.149.66 with SMTP id x63mr582416vkd.71.1472559124032; Tue, 30 Aug 2016 05:12:04 -0700 (PDT) Original-Received: by 10.176.4.41 with HTTP; Tue, 30 Aug 2016 05:11:43 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c08::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:206925 Archived-At: --001a1140f5587fb89b053b48e3f4 Content-Type: text/plain; charset=UTF-8 Hi Tino, Thanks for the proposal and the fix! I'm the long lost author of image-dired.el :) >From my viewpoint, and after just a quick overview of the changes, I think it looks good. If we can present more meaningful error messages to the user, it can only be good. I noticed you did a small change in the logic surrounding jpegtrans; IIUC you fallback to use "convert" if jpegtrans is not available. As long as you have tested both scenarios I'm fine with the change. The same goes for the other changes of course, that they are tested and works well. Someone else has to apply this to the Emacs source code however, since I'm not up-to-date with how commits are done these days. Thanks! /Mathias On Sun, Aug 28, 2016 at 4:58 PM, Tino Calancha wrote: > > image-dired uses several external programs. The file > introduces user options with the name of the executables; > for instance, image-dired-cmd-create-thumbnail-program > has default value 'convert'. > > If an user don't have installed one of these external programs, > and s?he run one function requiring that missing executable, > then the error is not very clear. > > For instance, calling image-dired-rotate-original when > image-dired-cmd-rotate-original-program is not installed throw an error: > 'Could not rotate image'. > For this case seems better to report that the required executable > is not available. Such error would avoid the need to read the code > to understand what was actually wrong. > > I propose a patch which set default value nil for the option > if the executable is not found. Every function using an external > program has a nil check for the option storing the executable name: > when the option is nil, the function throw an error reporting that the > option is nil. > > Do you think this proposal is useful? > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;;;;;;;;;;;;;;;;;;; > From 4cf0cb63adec2d5b6c89eee78645106d2479462f Mon Sep 17 00:00:00 2001 > From: Tino Calancha > Date: Sun, 28 Aug 2016 23:33:09 +0900 > Subject: [PATCH] image-dired: Report when a necessary executable is not > found > > * lisp/image-dired.el (image-dired-cmd-rotate-original-program) > (image-dired-cmd-create-thumbnail-program) > (image-dired-cmd-create-temp-image-program) > (image-dired-cmd-rotate-thumbnail-program) > (image-dired-cmd-write-exif-data-program) > (image-dired-cmd-read-exif-data-program): > Use executable-find to set the defaut value for this option. > (image-dired-cmd-rotate-original-program): > Search for program 'convert' if 'jpegtran' is not found. > (image-dired-cmd-rotate-original-options): > Set the default value consistent with the executable in > image-dired-cmd-rotate-original-program. > (image-dired-thumb-name, image-dired-display-image) > (image-dired-image-at-point-p, image-dired-rotate-original) > (image-dired-thumbnail-set-image-description) > (image-dired-set-exif-data): > Throw and error when the executable used in the function is not > found. > --- > lisp/image-dired.el | 110 ++++++++++++++++++++++++++++++ > ---------------------- > 1 file changed, 64 insertions(+), 46 deletions(-) > > diff --git a/lisp/image-dired.el b/lisp/image-dired.el > index 67b023d..2511e13 100644 > --- a/lisp/image-dired.el > +++ b/lisp/image-dired.el > @@ -224,7 +224,7 @@ image-dired-gallery-thumb-image-root-url > :group 'image-dired) > > (defcustom image-dired-cmd-create-thumbnail-program > - "convert" > + (executable-find "convert") > "Executable used to create thumbnail. > Used together with `image-dired-cmd-create-thumbnail-options'." > :type 'string > @@ -242,7 +242,7 @@ image-dired-cmd-create-thumbnail-options > :group 'image-dired) > > (defcustom image-dired-cmd-create-temp-image-program > - "convert" > + (executable-find "convert") > "Executable used to create temporary image. > Used together with `image-dired-cmd-create-temp-image-options'." > :type 'string > @@ -308,7 +308,7 @@ image-dired-cmd-create-standard-thumbnail-command > :group 'image-dired) > > (defcustom image-dired-cmd-rotate-thumbnail-program > - "mogrify" > + (executable-find "mogrify") > "Executable used to rotate thumbnail. > Used together with `image-dired-cmd-rotate-thumbnail-options'." > :type 'string > @@ -326,14 +326,20 @@ image-dired-cmd-rotate-thumbnail-options > :group 'image-dired) > > (defcustom image-dired-cmd-rotate-original-program > - "jpegtran" > + (cond ((executable-find "jpegtran")) > + ((executable-find "convert"))) > "Executable used to rotate original image. > Used together with `image-dired-cmd-rotate-original-options'." > :type 'string > :group 'image-dired) > > (defcustom image-dired-cmd-rotate-original-options > - "%p -rotate %d -copy all -outfile %t \"%o\"" > + (when image-dired-cmd-rotate-original-program > + (pcase image-dired-cmd-rotate-original-program > + ((pred (lambda (x) (string-match "jpegtran" x))) > + "%p -rotate %d -copy all -outfile %t \"%o\"") > + ((pred (lambda (x) (string-match "convert" x))) > + "%p -rotate %d \"%o\" %t"))) > "Format of command used to rotate original image. > Available options are %p which is replaced by > `image-dired-cmd-rotate-original-program', %d which is replaced by the > @@ -358,7 +364,7 @@ image-dired-rotate-original-ask-before-overwrite > :group 'image-dired) > > (defcustom image-dired-cmd-write-exif-data-program > - "exiftool" > + (executable-find "exiftool") > "Program used to write EXIF data to image. > Used together with `image-dired-cmd-write-exif-data-options'." > :type 'string > @@ -375,7 +381,7 @@ image-dired-cmd-write-exif-data-options > :group 'image-dired) > > (defcustom image-dired-cmd-read-exif-data-program > - "exiftool" > + (executable-find "exiftool") > "Program used to read EXIF data to image. > Used together with `image-dired-cmd-read-exif-data-program-options'." > :type 'string > @@ -615,6 +621,8 @@ image-dired-thumb-name > > (defun image-dired-create-thumb (original-file thumbnail-file) > "For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE." > + (unless image-dired-cmd-create-thumbnail-program > + (error "image-dired-cmd-create-thumbnail-program is nil")) > (let* ((width (int-to-string image-dired-thumb-width)) > (height (int-to-string image-dired-thumb-height)) > (modif-time (format "%.0f" (float-time (nth 5 (file-attributes > @@ -1810,6 +1818,8 @@ image-dired-display-image > (progn > (setq width (image-dired-display-window-width)) > (setq height (image-dired-display-window-height)) > + (unless image-dired-cmd-create-temp-image-program > + (error "image-dired-cmd-create-temp-image-program is nil")) > (setq command > (format-spec > image-dired-cmd-create-temp-image-options > @@ -1866,20 +1876,22 @@ image-dired-image-at-point-p > > (defun image-dired-rotate-thumbnail (degrees) > "Rotate thumbnail DEGREES degrees." > - (if (not (image-dired-image-at-point-p)) > - (message "No thumbnail at point") > - (let ((file (image-dired-thumb-name (image-dired-original-file-nam > e))) > - command) > - (setq command (format-spec > - image-dired-cmd-rotate-thumbnail-options > - (list > - (cons ?p image-dired-cmd-rotate-thumbnail-program) > - (cons ?d degrees) > - (cons ?t (expand-file-name file))))) > - (call-process shell-file-name nil nil nil shell-command-switch > command) > - ;; Clear the cache to refresh image. I wish I could just refresh > - ;; the current file but I do not know how to do that. Yet... > - (clear-image-cache)))) > + (unless (image-dired-image-at-point-p) > + (message "No thumbnail at point")) > + (unless image-dired-cmd-rotate-thumbnail-program > + (error "image-dired-cmd-rotate-thumbnail-program is nil")) > + (let ((file (image-dired-thumb-name (image-dired-original-file-name))) > + command) > + (setq command (format-spec > + image-dired-cmd-rotate-thumbnail-options > + (list > + (cons ?p image-dired-cmd-rotate-thumbnail-program) > + (cons ?d degrees) > + (cons ?t (expand-file-name file))))) > + (call-process shell-file-name nil nil nil shell-command-switch > command) > + ;; Clear the cache to refresh image. I wish I could just refresh > + ;; the current file but I do not know how to do that. Yet... > + (clear-image-cache))) > > (defun image-dired-rotate-thumbnail-left () > "Rotate thumbnail left (counter clockwise) 90 degrees. > @@ -1908,31 +1920,33 @@ image-dired-refresh-thumb > > (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)) > - (error "Only JPEG images can be rotated!")) > - (setq command (format-spec > - image-dired-cmd-rotate-original-options > - (list > - (cons ?p image-dired-cmd-rotate-original-program) > - (cons ?d degrees) > - (cons ?o (expand-file-name file)) > - (cons ?t image-dired-temp-rotate-image-file)))) > - (if (not (= 0 (call-process shell-file-name nil nil nil > - shell-command-switch command))) > - (error "Could not rotate image") > - (image-dired-display-image image-dired-temp-rotate-image-file) > - (if (or (and image-dired-rotate-original-ask-before-overwrite > - (y-or-n-p > - "Rotate to temp file OK. Overwrite original image? > ")) > - (not image-dired-rotate-original-ask-before-overwrite)) > - (progn > - (copy-file image-dired-temp-rotate-image-file file t) > - (image-dired-refresh-thumb)) > - (image-dired-display-image file)))))) > + (unless (image-dired-image-at-point-p) > + (message "No image at point")) > + (unless image-dired-cmd-rotate-original-program > + (error "image-dired-cmd-rotate-original-program is nil")) > + (let ((file (image-dired-original-file-name)) > + command) > + (if (not (string-match "\\.[jJ][pP[eE]?[gG]$" file)) > + (error "Only JPEG images can be rotated!")) > + (setq command (format-spec > + image-dired-cmd-rotate-original-options > + (list > + (cons ?p image-dired-cmd-rotate-original-program) > + (cons ?d degrees) > + (cons ?o (expand-file-name file)) > + (cons ?t image-dired-temp-rotate-image-file)))) > + (if (not (= 0 (call-process shell-file-name nil nil nil > + shell-command-switch command))) > + (error "Could not rotate image") > + (image-dired-display-image image-dired-temp-rotate-image-file) > + (if (or (and image-dired-rotate-original-ask-before-overwrite > + (y-or-n-p > + "Rotate to temp file OK. Overwrite original image? > ")) > + (not image-dired-rotate-original-ask-before-overwrite)) > + (progn > + (copy-file image-dired-temp-rotate-image-file file t) > + (image-dired-refresh-thumb)) > + (image-dired-display-image file))))) > > (defun image-dired-rotate-original-left () > "Rotate original image left (counter clockwise) 90 degrees." > @@ -1987,6 +2001,8 @@ image-dired-thumbnail-set-image-description > > (defun image-dired-set-exif-data (file tag-name tag-value) > "In FILE, set EXIF tag TAG-NAME to value TAG-VALUE." > + (unless image-dired-cmd-write-exif-data-program > + (error "image-dired-cmd-write-exif-data-program is nil")) > (let (command) > (setq command (format-spec > image-dired-cmd-write-exif-data-options > @@ -1999,6 +2015,8 @@ image-dired-set-exif-data > > (defun image-dired-get-exif-data (file tag-name) > "From FILE, return EXIF tag TAG-NAME." > + (unless image-dired-cmd-read-exif-data-program > + (error "image-dired-cmd-read-exif-data-program is nil")) > (let ((buf (get-buffer-create "*image-dired-get-exif-data*")) > command tag-value) > (setq command (format-spec > -- > 2.9.3 > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;;;;;;;;;;;;;;;;;;; > > > In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.9) > of 2016-08-28 > Repository revision: 7fcce24e75b8281621a0b8816dc58cbdc05fdc91 > > > --001a1140f5587fb89b053b48e3f4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Tino,

Thanks for the proposal and th= e fix!

I'm the long lost author of image-dired= .el :)

From my viewpoint, and after just a quick o= verview of the changes, I think it looks good. If we can present more meani= ngful error messages to the user, it can only be good. I noticed you did a = small change in the logic surrounding jpegtrans; IIUC you fallback to use &= quot;convert" if jpegtrans is not available. As long as you have teste= d both scenarios I'm fine with the change. The same goes for the other = changes of course, that they are tested and works well.

Someone else has to apply this to the Emacs source code however, sinc= e I'm not up-to-date with how commits are done these days.
Thanks!

/Mathias

On Sun, Aug 28, 2016 at 4:= 58 PM, Tino Calancha <tino.calancha@gmail.com> wrote:<= br>

image-dired uses several external programs.=C2=A0 The file
introduces user options with the name of the executables;
for instance, image-dired-cmd-create-thumbnail-program
has default value 'convert'.

If an user don't have installed one of these external programs,
and s?he run one function requiring that missing executable,
then the error is not very clear.

For instance, calling image-dired-rotate-original when
image-dired-cmd-rotate-original-program is not installed throw an erro= r:
'Could not rotate image'.
For this case seems better to report that the required executable
is not available.=C2=A0 Such error would avoid the need to read the code to understand what was actually wrong.

I propose a patch which set default value nil for the option
if the executable is not found.=C2=A0 Every function using an external
program has a nil check for the option storing the executable name:
when the option is nil, the function throw an error reporting that the
option is nil.

Do you think this proposal is useful?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;
>From 4cf0cb63adec2d5b6c89eee78645106d2479462f Mon Sep 17 00:00:00 2001=
From: Tino Calancha <tino.calancha@gmail.com>
Date: Sun, 28 Aug 2016 23:33:09 +0900
Subject: [PATCH] image-dired: Report when a necessary executable is not fou= nd

* lisp/image-dired.el (image-dired-cmd-rotate-original-program)
(image-dired-cmd-create-thumbnail-program)
(image-dired-cmd-create-temp-image-program)
(image-dired-cmd-rotate-thumbnail-program)
(image-dired-cmd-write-exif-data-program)
(image-dired-cmd-read-exif-data-program):
Use executable-find to set the defaut value for this option.
(image-dired-cmd-rotate-original-program):
Search for program 'convert' if 'jpegtran' is not found. (image-dired-cmd-rotate-original-options):
Set the default value consistent with the executable in
image-dired-cmd-rotate-original-program.
(image-dired-thumb-name, image-dired-display-image)
(image-dired-image-at-point-p, image-dired-rotate-original)
(image-dired-thumbnail-set-image-description)
(image-dired-set-exif-data):
Throw and error when the executable used in the function is not
found.
---
=C2=A0lisp/image-dired.el | 110 ++++++++++++++++++++++++++++++--------= --------------
=C2=A01 file changed, 64 insertions(+), 46 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 67b023d..2511e13 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -224,7 +224,7 @@ image-dired-gallery-thumb-image-root-url
=C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-create-thumbnail-program
-=C2=A0 "convert"
+=C2=A0 (executable-find "convert")
=C2=A0 =C2=A0"Executable used to create thumbnail.
=C2=A0Used together with `image-dired-cmd-create-thumbnail-options'= ;."
=C2=A0 =C2=A0:type 'string
@@ -242,7 +242,7 @@ image-dired-cmd-create-thumbnail-options
=C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-create-temp-image-program
-=C2=A0 "convert"
+=C2=A0 (executable-find "convert")
=C2=A0 =C2=A0"Executable used to create temporary image.
=C2=A0Used together with `image-dired-cmd-create-temp-image-options= 9;."
=C2=A0 =C2=A0:type 'string
@@ -308,7 +308,7 @@ image-dired-cmd-create-standard-thumbnail-command<= br> =C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-rotate-thumbnail-program
-=C2=A0 "mogrify"
+=C2=A0 (executable-find "mogrify")
=C2=A0 =C2=A0"Executable used to rotate thumbnail.
=C2=A0Used together with `image-dired-cmd-rotate-thumbnail-options'= ;."
=C2=A0 =C2=A0:type 'string
@@ -326,14 +326,20 @@ image-dired-cmd-rotate-thumbnail-options
=C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-rotate-original-program
-=C2=A0 "jpegtran"
+=C2=A0 (cond ((executable-find "jpegtran"))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 ((executable-find "convert")))
=C2=A0 =C2=A0"Executable used to rotate original image.
=C2=A0Used together with `image-dired-cmd-rotate-original-options'= ."
=C2=A0 =C2=A0:type 'string
=C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-rotate-original-options
-=C2=A0 "%p -rotate %d -copy all -outfile %t \"%o\"" +=C2=A0 (when image-dired-cmd-rotate-original-program
+=C2=A0 =C2=A0 (pcase image-dired-cmd-rotate-original-program
+=C2=A0 =C2=A0 =C2=A0 ((pred (lambda (x) (string-match "jpegtran"= x)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"%p -rotate %d -copy all -outfile %t \&quo= t;%o\"")
+=C2=A0 =C2=A0 =C2=A0 ((pred (lambda (x) (string-match "convert" = x)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"%p -rotate %d \"%o\" %t"))= )
=C2=A0 =C2=A0"Format of command used to rotate original image.
=C2=A0Available options are %p which is replaced by
=C2=A0`image-dired-cmd-rotate-original-program', %d which is repla= ced by the
@@ -358,7 +364,7 @@ image-dired-rotate-original-ask-before-overwrite =C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-write-exif-data-program
-=C2=A0 "exiftool"
+=C2=A0 (executable-find "exiftool")
=C2=A0 =C2=A0"Program used to write EXIF data to image.
=C2=A0Used together with `image-dired-cmd-write-exif-data-options'= ."
=C2=A0 =C2=A0:type 'string
@@ -375,7 +381,7 @@ image-dired-cmd-write-exif-data-options
=C2=A0 =C2=A0:group 'image-dired)

=C2=A0(defcustom image-dired-cmd-read-exif-data-program
-=C2=A0 "exiftool"
+=C2=A0 (executable-find "exiftool")
=C2=A0 =C2=A0"Program used to read EXIF data to image.
=C2=A0Used together with `image-dired-cmd-read-exif-data-program-optio= ns'."
=C2=A0 =C2=A0:type 'string
@@ -615,6 +621,8 @@ image-dired-thumb-name

=C2=A0(defun image-dired-create-thumb (original-file thumbnail-file)
=C2=A0 =C2=A0"For ORIGINAL-FILE, create thumbnail image named THUMBNAI= L-FILE."
+=C2=A0 (unless image-dired-cmd-create-thumbnail-program
+=C2=A0 =C2=A0 (error "image-dired-cmd-create-thumbnail-program i= s nil"))
=C2=A0 =C2=A0(let* ((width (int-to-string image-dired-thumb-width))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (height (int-to-string image-dired-thumb= -height))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modif-time (format "%.0f" (fl= oat-time (nth 5 (file-attributes
@@ -1810,6 +1818,8 @@ image-dired-display-image
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(progn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq width (image-dired-display-w= indow-width))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq height (image-dired-display-= window-height))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless image-dired-cmd-create-temp-im<= wbr>age-program
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "image-dired-cmd-cre= ate-temp-image-program is nil"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq command
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(format-spec<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 image-dired-= cmd-create-temp-image-options
@@ -1866,20 +1876,22 @@ image-dired-image-at-point-p

=C2=A0(defun image-dired-rotate-thumbnail (degrees)
=C2=A0 =C2=A0"Rotate thumbnail DEGREES degrees."
-=C2=A0 (if (not (image-dired-image-at-point-p))
-=C2=A0 =C2=A0 =C2=A0 (message "No thumbnail at point")
-=C2=A0 =C2=A0 (let ((file (image-dired-thumb-name (image-dired-original-fi= le-name)))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command)
-=C2=A0 =C2=A0 =C2=A0 (setq command (format-spec
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0image-dired-cmd-rotate-thumbnail-options
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(list
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?p image-dired-cmd-rotate-thumbnail-program)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?d degrees)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?t (expand-file-name file)))))
-=C2=A0 =C2=A0 =C2=A0 (call-process shell-file-name nil nil nil shell-comma= nd-switch command)
-=C2=A0 =C2=A0 =C2=A0 ;; Clear the cache to refresh image. I wish I could j= ust refresh
-=C2=A0 =C2=A0 =C2=A0 ;; the current file but I do not know how to do that.= Yet...
-=C2=A0 =C2=A0 =C2=A0 (clear-image-cache))))
+=C2=A0 (unless (image-dired-image-at-point-p)
+=C2=A0 =C2=A0 (message "No thumbnail at point"))
+=C2=A0 (unless image-dired-cmd-rotate-thumbnail-program
+=C2=A0 =C2=A0 (error "image-dired-cmd-rotate-thumbnail-program i= s nil"))
+=C2=A0 (let ((file (image-dired-thumb-name (image-dired-original-file-nam<= wbr>e)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 command)
+=C2=A0 =C2=A0 (setq command (format-spec
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0image= -dired-cmd-rotate-thumbnail-options
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?p image-dired-cmd-rotate-thumbnail-program)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?d degrees)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?t (expand-file-name file)))))
+=C2=A0 =C2=A0 (call-process shell-file-name nil nil nil shell-command-swit= ch command)
+=C2=A0 =C2=A0 ;; Clear the cache to refresh image. I wish I could just ref= resh
+=C2=A0 =C2=A0 ;; the current file but I do not know how to do that. Yet...=
+=C2=A0 =C2=A0 (clear-image-cache)))

=C2=A0(defun image-dired-rotate-thumbnail-left ()
=C2=A0 =C2=A0"Rotate thumbnail left (counter clockwise) 90 degrees. @@ -1908,31 +1920,33 @@ image-dired-refresh-thumb

=C2=A0(defun image-dired-rotate-original (degrees)
=C2=A0 =C2=A0"Rotate original image DEGREES degrees."
-=C2=A0 (if (not (image-dired-image-at-point-p))
-=C2=A0 =C2=A0 =C2=A0 (message "No image at point")
-=C2=A0 =C2=A0 (let ((file (image-dired-original-file-name))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command)
-=C2=A0 =C2=A0 =C2=A0 (if (not (string-match "\\.[jJ][pP[eE]?[gG]$&quo= t; file))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Only JPEG images can be ro= tated!"))
-=C2=A0 =C2=A0 =C2=A0 (setq command (format-spec
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0image-dired-cmd-rotate-original-options
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(list
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?p image-dired-cmd-rotate-original-program)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?d degrees)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?o (expand-file-name file))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (cons ?t image-dired-temp-rotate-image-file))))
-=C2=A0 =C2=A0 =C2=A0 (if (not (=3D 0 (call-process shell-file-name nil nil= nil
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shell-command-switch command))= )
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Could not rotate image&quo= t;)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (image-dired-display-image image-dired-temp-ro= tate-image-file)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (or (and image-dired-rotate-original-ask-before-overwrite
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(y-or-n-p
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0"Rotate to temp file OK.=C2=A0 Overwrite original image? ")) -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (not image-dired-r= otate-original-ask-before-overwrite))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (copy-file image-dired-te= mp-rotate-image-file file t)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (image-dired-refresh-thum= b))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (image-dired-display-image file)))))) +=C2=A0 (unless (image-dired-image-at-point-p)
+=C2=A0 =C2=A0 (message "No image at point"))
+=C2=A0 (unless image-dired-cmd-rotate-original-program
+=C2=A0 =C2=A0 (error "image-dired-cmd-rotate-original-program is= nil"))
+=C2=A0 (let ((file (image-dired-original-file-name))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 command)
+=C2=A0 =C2=A0 (if (not (string-match "\\.[jJ][pP[eE]?[gG]$" file= ))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Only JPEG images can be rotated!&= quot;))
+=C2=A0 =C2=A0 (setq command (format-spec
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0image= -dired-cmd-rotate-original-options
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?p image-dired-cmd-rotate-original-program)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?d degrees)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?o (expand-file-name file))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (con= s ?t image-dired-temp-rotate-image-file))))
+=C2=A0 =C2=A0 (if (not (=3D 0 (call-process shell-file-name nil nil nil +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 shell-command-switch command)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Could not rotate image")
+=C2=A0 =C2=A0 =C2=A0 (image-dired-display-image image-dired-temp-rotate-im= age-file)
+=C2=A0 =C2=A0 =C2=A0 (if (or (and image-dired-rotate-original-ask-bef= ore-overwrite
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(y-or= -n-p
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quo= t;Rotate to temp file OK.=C2=A0 Overwrite original image? "))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (not image-dired-rotate-o= riginal-ask-before-overwrite))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (copy-file image-dired-temp-rota= te-image-file file t)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (image-dired-refresh-thumb))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (image-dired-display-image file)))))

=C2=A0(defun image-dired-rotate-original-left ()
=C2=A0 =C2=A0"Rotate original image left (counter clockwise) 90 degree= s."
@@ -1987,6 +2001,8 @@ image-dired-thumbnail-set-image-description

=C2=A0(defun image-dired-set-exif-data (file tag-name tag-value)
=C2=A0 =C2=A0"In FILE, set EXIF tag TAG-NAME to value TAG-VALUE."=
+=C2=A0 (unless image-dired-cmd-write-exif-data-program
+=C2=A0 =C2=A0 (error "image-dired-cmd-write-exif-data-program is= nil"))
=C2=A0 =C2=A0(let (command)
=C2=A0 =C2=A0 =C2=A0(setq command (format-spec
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 image= -dired-cmd-write-exif-data-options
@@ -1999,6 +2015,8 @@ image-dired-set-exif-data

=C2=A0(defun image-dired-get-exif-data (file tag-name)
=C2=A0 =C2=A0"From FILE, return EXIF tag TAG-NAME."
+=C2=A0 (unless image-dired-cmd-read-exif-data-program
+=C2=A0 =C2=A0 (error "image-dired-cmd-read-exif-data-program is = nil"))
=C2=A0 =C2=A0(let ((buf (get-buffer-create "*image-dired-get-exif-data= *"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0command tag-value)
=C2=A0 =C2=A0 =C2=A0(setq command (format-spec
--
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;


In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.9)
=C2=A0of 2016-08-28
Repository revision: 7fcce24e75b8281621a0b8816dc58cbdc05fdc91



--001a1140f5587fb89b053b48e3f4--