emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/helm b738e7b65d 4/7: Better handling of errors in mcp


From: ELPA Syncer
Subject: [nongnu] elpa/helm b738e7b65d 4/7: Better handling of errors in mcp
Date: Wed, 21 Sep 2022 01:59:10 -0400 (EDT)

branch: elpa/helm
commit b738e7b65dd6fe9ee5ed1f957f3feacd1e2f0a6f
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Better handling of errors in mcp
---
 helm-files.el | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/helm-files.el b/helm-files.el
index 989af7ab7f..22458b2657 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -6002,8 +6002,10 @@ be directories."
          (targets (cdr mkd))
          (skipped 0)
          operations)
-    (cl-assert (file-regular-p file) nil (format "Not a regular file `%s'" 
file))
-    (cl-assert targets nil (format "No destination specified for file `%s'" 
file))
+    (cl-assert (file-regular-p file) nil (format "ERROR: Not a regular file 
`%s'" file))
+    (cl-assert targets nil (format "ERROR: No destination specified for file 
`%s'" file))
+    (cl-assert (cl-loop for f in targets always (file-directory-p f)) nil
+               "ERROR: Destinations must be directories")
     (when targets
       (cl-loop with yes-for-all
                for dest in targets
@@ -6031,25 +6033,26 @@ be directories."
                       (push (list file (file-name-as-directory dest) 
overwrite) operations)
                     (cl-incf skipped))
                else do (cl-incf skipped))
-      (async-start
-       `(lambda ()
-          (require 'cl-lib)
-          (cl-loop with copies = 0
-                   with skipped = ,skipped
-                   for (file dest overwrite) in ',operations
-                   do (condition-case _err
-                          (progn
-                            (copy-file file dest overwrite)
-                            (cl-incf copies))
-                        (file-error (cl-incf skipped)))
-                   finally return (list file copies skipped)))
-       (lambda (result)
-         (let ((copied (nth 1 result)))
-           (message "Mcp done, %s %s of %s done, %s files skipped"
-                    copied (if (> copied 1)
-                               "copies" "copy")
-                    (helm-basename (nth 0 result))
-                    (nth 2 result))))))))
+      (when operations
+        (async-start
+         `(lambda ()
+            (require 'cl-lib)
+            (cl-loop with copies = 0
+                     with skipped = ,skipped
+                     for (file dest overwrite) in ',operations
+                     do (condition-case _err
+                            (progn
+                              (copy-file file dest overwrite)
+                              (cl-incf copies))
+                          (file-error (cl-incf skipped)))
+                     finally return (list file copies skipped)))
+         (lambda (result)
+           (let ((copied (nth 1 result)))
+             (message "Mcp done, %s %s of %s done, %s files skipped"
+                      copied (if (> copied 1)
+                                 "copies" "copy")
+                      (helm-basename (nth 0 result))
+                      (nth 2 result)))))))))
 
 (helm-make-command-from-action helm-ff-run-mcp
     "Copy the car of marked candidates to the remaining marked candidates."



reply via email to

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