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

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

[nongnu] elpa/helm 5c5fb8d5d3 08/14: Make helm-ff-compress-marked-files


From: ELPA Syncer
Subject: [nongnu] elpa/helm 5c5fb8d5d3 08/14: Make helm-ff-compress-marked-files async as well
Date: Fri, 15 Mar 2024 04:00:28 -0400 (EDT)

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

    Make helm-ff-compress-marked-files async as well
---
 helm-files.el | 45 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/helm-files.el b/helm-files.el
index 31eb17f2f6..c6fa50de20 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -1525,24 +1525,36 @@ This reproduce the behavior of \"cp --backup=numbered 
from to\"."
 
 (defun helm-ff-compress-marked-files (_candidate)
   "Compress or uncompress marked files with `dired-compress-file'."
-  (let* ((files (helm-marked-candidates :with-wildcard t))
-         (len 0))
+  (let* ((files (helm-marked-candidates :with-wildcard t)))
     (if (not (with-helm-display-marked-candidates
                helm-marked-buffer-name
                (mapcar #'abbreviate-file-name files)
                (y-or-n-p (format "Compress or uncompress *%s File(s)" (length 
files)))))
         (message "(No (un)compression performed)")
-      (cl-dolist (i files)
-        (when (helm-ff--dired-compress-file i)
-          (cl-incf len)))
-      (message "%s File(s) (un)compressed" len))))
-
-(defun helm-ff--dired-compress-file (file)
-  ;; `dired-compress-file' doesn't take care of binding `default-directory' 
when
-  ;; uncompressing FILE, as a result FILE is uncompressed in the directory 
where
-  ;; helm was started i.e. the current value of `default-directory'.
-  (with-helm-default-directory helm-ff-default-directory
-    (dired-compress-file file)))
+      (process-put
+       (async-start
+        `(lambda ()
+           (require 'dired-aux)
+           (let ((len 0))
+             (dolist (i ',files)
+               (let ((default-directory (file-name-directory i)))
+                 (when (dired-compress-file i)
+                   (cl-incf len))))
+             len))
+        `(lambda (result)
+           (helm-ff--compress-async-modeline-mode -1)
+           (message "%s File(s) (un)compressed" result)
+           (run-with-timer
+            0.1 nil
+            (lambda (num-files)
+              (dired-async-mode-line-message
+               "%s %d/%d file(s) done"
+               'helm-delete-async-message
+               "Compressing"
+               num-files (length ',files)))
+            result)))
+       'helm-async-compress t)
+      (helm-ff--compress-async-modeline-mode 1))))
 
 (defun helm-ff-chmod (_candidate)
   "Set file mode on marked files.
@@ -5948,6 +5960,13 @@ and `dired-compress-files-alist'."
            do (setq base (fill-common-string-prefix base file))
            finally return (file-name-directory base)))
 
+(defun helm-ff--dired-compress-file (file)
+  ;; `dired-compress-file' doesn't take care of binding `default-directory' 
when
+  ;; uncompressing FILE, as a result FILE is uncompressed in the directory 
where
+  ;; helm was started i.e. the current value of `default-directory'.
+  (with-helm-default-directory helm-ff-default-directory
+    (dired-compress-file file)))
+
 (defun helm-ff-quick-compress (_candidate)
   "Compress or uncompress file CANDIDATE without quitting."
   (with-helm-window



reply via email to

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