]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer `when' instead of 1-branch `if'
authorTino Calancha <tino.calancha@gmail.com>
Mon, 26 Jun 2017 08:20:42 +0000 (17:20 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Mon, 26 Jun 2017 08:20:42 +0000 (17:20 +0900)
* 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

index aede83e61ccdbf8b70d042bca6304abbac24a285..121bebeb651e829905d9394e590a22e704bd4e31 100644 (file)
@@ -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 ""