From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Re: master ca47390: image-dired: Report when a necessary executable is not found Date: Tue, 6 Sep 2016 03:00:37 +0900 (JST) Message-ID: References: <20160904134431.30494.94659@vcs.savannah.gnu.org> <20160904134431.7513F220140@vcs.savannah.gnu.org> <9ba96760-15da-e7f5-a4e5-4a93ecd49f7a@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-2012461823-1473098440=:18231" X-Trace: blaine.gmane.org 1473098500 9015 195.159.176.226 (5 Sep 2016 18:01:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Sep 2016 18:01:40 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: emacs-devel@gnu.org To: =?ISO-8859-15?Q?Cl=E9ment_Pit--Claudel?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 05 20:01:35 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 1bgyD2-00019G-QT for ged-emacs-devel@m.gmane.org; Mon, 05 Sep 2016 20:01:29 +0200 Original-Received: from localhost ([::1]:56068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgyD0-0008S4-BC for ged-emacs-devel@m.gmane.org; Mon, 05 Sep 2016 14:01:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgyCN-0008Ru-6u for emacs-devel@gnu.org; Mon, 05 Sep 2016 14:00:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgyCI-00069p-7e for emacs-devel@gnu.org; Mon, 05 Sep 2016 14:00:47 -0400 Original-Received: from mail-pf0-x230.google.com ([2607:f8b0:400e:c00::230]:33524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgyCH-00069h-T3 for emacs-devel@gnu.org; Mon, 05 Sep 2016 14:00:42 -0400 Original-Received: by mail-pf0-x230.google.com with SMTP id g202so43214953pfb.0 for ; Mon, 05 Sep 2016 11:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=5hzCRlxKdqGurGQaCO48BM6pRog/Ig/HPsuiSffmU54=; b=FQdFiuCQr13pfrAZX2G8+3+QOf69UAmxz2RDuWHssVTc05mA34pvvAv2ApNjGlXJyG I4O8l1tymGZoAWoxBGHZqtHNFRFRaD0KXnAirh/EDdsYcvPyTY1EzWHWo/RfZuMwghAE 8CnTK5rDjRBEG2vTb3u+LhWb2BmQhaYceNOzP5pc06WrQxK266Zb0S6slVnIFf4zXXbC uBSvbVHn9OQJLret/hLB5faa9/+5q1RuM/Ex9bPwhPateww7qhYeICKcfvdpb5sJKF9U M6jBaXJH+flFawF3nAtNpda9bJQwLZggHCc+Hw1xBRNM4YMrwR0DOdNFrs8hAG6XK5Ea i2Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=5hzCRlxKdqGurGQaCO48BM6pRog/Ig/HPsuiSffmU54=; b=UL4P+ob2Wni0en/MithKZQPmmo0PjLFO1JhJwqpKGtGjhZW8FUQK9krQwEdqQzMtzy XqQjxGVgeMOYci+gVZy9egsbB7wQdt0SaH9ViwBR3YVzHCfXLLAeQXkjQtBMLVRVojXG lqosJL1pSzYiccpoQHzv6ITanUgElMd28UFO6WC5oBQQbTZ1KUcYdkPKkzEUHDOirN1o FsCfPe6Ru3CtxwIzuQTj75qR2oxmzHjbVtaZHzuKzYW9hW9nBrWOVVGpsMK7ChuoC0kE /cjt48hcIlUyxJkjqpmxT4SUVpkDf7X1DYoTpPUUp4kVk2e6fz6CUeUc8mSVJbzAi7TY YJkg== X-Gm-Message-State: AE9vXwOHM3EcJ+mMeMlsvx7Z/eg6bt+Ak19+Pl4teicu3JiL/wHMjptmrkJz59jYo3mO1w== X-Received: by 10.98.23.140 with SMTP id 134mr4901688pfx.96.1473098440848; Mon, 05 Sep 2016 11:00:40 -0700 (PDT) Original-Received: from calancha-pc (69.191.218.133.dy.bbexcite.jp. [133.218.191.69]) by smtp.gmail.com with ESMTPSA id bl6sm25360348pad.6.2016.09.05.11.00.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Sep 2016 11:00:40 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <9ba96760-15da-e7f5-a4e5-4a93ecd49f7a@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::230 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:207203 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2012461823-1473098440=:18231 Content-Type: text/plain; format=flowed; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT On Mon, 5 Sep 2016, Clément Pit--Claudel wrote: >Looks good, but maybe you could extract this to a separate function that >takes the variable name and produces the error? There's a bit of > duplication in the patch you posted. Thanks for your help. Sure, how about this new patch? It reverts ca473907, so that the options storing the executable names are never nil, i.e., there is no need to reset the options after installing the missing executables. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 37a295e7149b459ea1cccfbf0ce49c5a50676a52 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Tue, 6 Sep 2016 02:50:56 +0900 Subject: [PATCH] image-dired: Signal an error before calling a missing executable Reverts commit ca473907 * lisp/image-dired.el (image-dired--check-executable-exists): New defun. Throw and error when the executable arg is missing. (image-dired-display-image, image-dired-rotate-thumbnail) (image-dired-rotate-original, image-dired-set-exif-data) (image-dired-get-exif-data): Use it. --- lisp/image-dired.el | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 5ac4600..07f66e0 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 - (executable-find "convert") + "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 - (executable-find "convert") + "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 - (executable-find "mogrify") + "mogrify" "Executable used to rotate thumbnail. Used together with `image-dired-cmd-rotate-thumbnail-options'." :type 'string @@ -326,20 +326,14 @@ image-dired-cmd-rotate-thumbnail-options :group 'image-dired) (defcustom image-dired-cmd-rotate-original-program - (cond ((executable-find "jpegtran")) - ((executable-find "convert"))) + "jpegtran" "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 - (when image-dired-cmd-rotate-original-program - (pcase image-dired-cmd-rotate-original-program - ((pred (lambda (x) (string-match-p "jpegtran" x))) - "%p -rotate %d -copy all -outfile %t \"%o\"") - ((pred (lambda (x) (string-match-p "convert" x))) - "%p -rotate %d \"%o\" %t"))) + "%p -rotate %d -copy all -outfile %t \"%o\"" "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 @@ -364,7 +358,7 @@ image-dired-rotate-original-ask-before-overwrite :group 'image-dired) (defcustom image-dired-cmd-write-exif-data-program - (executable-find "exiftool") + "exiftool" "Program used to write EXIF data to image. Used together with `image-dired-cmd-write-exif-data-options'." :type 'string @@ -381,7 +375,7 @@ image-dired-cmd-write-exif-data-options :group 'image-dired) (defcustom image-dired-cmd-read-exif-data-program - (executable-find "exiftool") + "exiftool" "Program used to read EXIF data to image. Used together with `image-dired-cmd-read-exif-data-program-options'." :type 'string @@ -619,10 +613,14 @@ image-dired-thumb-name (file-name-base f) (file-name-extension f)))))) +(defun image-dired--check-executable-exists (executable) + (unless (executable-find (symbol-value executable)) + (error "Executable %S not found" executable))) + (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")) + (image-dired--check-executable-exists + 'image-dired-cmd-create-thumbnail-program) (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 @@ -1820,8 +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")) + (image-dired--check-executable-exists + 'image-dired-cmd-create-temp-image-program) (setq command (format-spec image-dired-cmd-create-temp-image-options @@ -1878,8 +1876,8 @@ image-dired-image-at-point-p (defun image-dired-rotate-thumbnail (degrees) "Rotate thumbnail DEGREES degrees." - (unless image-dired-cmd-rotate-thumbnail-program - (error "image-dired-cmd-rotate-thumbnail-program is nil")) + (image-dired--check-executable-exists + 'image-dired-cmd-rotate-thumbnail-program) (if (not (image-dired-image-at-point-p)) (message "No thumbnail at point") (let ((file (image-dired-thumb-name (image-dired-original-file-name))) @@ -1924,8 +1922,8 @@ image-dired-rotate-original "Rotate original image DEGREES degrees." (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")) + (image-dired--check-executable-exists + 'image-dired-cmd-rotate-original-program) (let ((file (image-dired-original-file-name)) command) (unless (eq 'jpeg (image-type file)) @@ -2002,8 +2000,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")) + (image-dired--check-executable-exists + 'image-dired-cmd-write-exif-data-program) (let (command) (setq command (format-spec image-dired-cmd-write-exif-data-options @@ -2016,8 +2014,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")) + (image-dired--check-executable-exists + 'image-dired-cmd-read-exif-data-program) (let ((buf (get-buffer-create "*image-dired-get-exif-data*")) command tag-value) (setq command (format-spec -- 2.9.3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Repository revision: 62e4dc4660cb3b29cfffcad0639e51c7f382ced8 --8323329-2012461823-1473098440=:18231--