emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b9e17e2: Prefer `when' instead of 1-branch `if'


From: Tino Calancha
Subject: [Emacs-diffs] master b9e17e2: Prefer `when' instead of 1-branch `if'
Date: Mon, 26 Jun 2017 04:23:10 -0400 (EDT)

branch: master
commit b9e17e2dc6ed81a32b3baca5d49dbde362477dbe
Author: Tino Calancha <address@hidden>
Commit: Tino Calancha <address@hidden>

    Prefer `when' instead of 1-branch `if'
    
    * lisp/dired-aux.el (dired-do-shell-command): Store condition value
    in local variable ok.
    Use `when' instead of 1-branch `if'.
---
 lisp/dired-aux.el | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index aede83e..121bebe 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -707,29 +707,28 @@ can be produced by `dired-get-marked-files', for example."
   (let* ((on-each (not (string-match-p dired-star-subst-regexp command)))
         (no-subst (not (string-match-p dired-quark-subst-regexp command)))
         (star (string-match-p "\\*" command))
-        (qmark (string-match-p "\\?" command)))
-    ;; Get confirmation for wildcards that may have been meant
-    ;; to control substitution of a file name or the file name list.
-    (if (cond ((not (or on-each no-subst))
-              (error "You can not combine `*' and `?' substitution marks"))
-             ((and star on-each)
-              (y-or-n-p (format-message
-                         "Confirm--do you mean to use `*' as a wildcard? ")))
-             ((and qmark no-subst)
-              (y-or-n-p (format-message
-                         "Confirm--do you mean to use `?' as a wildcard? ")))
-             (t))
-       (if on-each
-           (dired-bunch-files
-            (- 10000 (length command))
-            (lambda (&rest files)
-              (dired-run-shell-command
-               (dired-shell-stuff-it command files t arg)))
-            nil
-            file-list)
-         ;; execute the shell command
-         (dired-run-shell-command
-          (dired-shell-stuff-it command file-list nil arg))))))
+        (qmark (string-match-p "\\?" command))
+         ;; Get confirmation for wildcards that may have been meant
+         ;; to control substitution of a file name or the file name list.
+         (ok (cond ((not (or on-each no-subst))
+                   (error "You can not combine `*' and `?' substitution 
marks"))
+                  ((and star on-each)
+                   (y-or-n-p (format-message
+                              "Confirm--do you mean to use `*' as a wildcard? 
")))
+                  ((and qmark no-subst)
+                   (y-or-n-p (format-message
+                              "Confirm--do you mean to use `?' as a wildcard? 
")))
+                  (t))))
+    (when ok
+      (if on-each
+         (dired-bunch-files (- 10000 (length command))
+                            (lambda (&rest files)
+                              (dired-run-shell-command
+                                (dired-shell-stuff-it command files t arg)))
+                            nil file-list)
+       ;; execute the shell command
+       (dired-run-shell-command
+        (dired-shell-stuff-it command file-list nil arg))))))
 
 ;; Might use {,} for bash or csh:
 (defvar dired-mark-prefix ""



reply via email to

[Prev in Thread] Current Thread [Next in Thread]