[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2db438b 029/187: dired-async now shows progress using over
From: |
Michael Albinus |
Subject: |
[elpa] master 2db438b 029/187: dired-async now shows progress using overlays |
Date: |
Wed, 30 Dec 2015 11:49:30 +0000 |
branch: master
commit 2db438be9567c3516b33a569f29c1a807212227f
Author: John Wiegley <address@hidden>
Commit: John Wiegley <address@hidden>
dired-async now shows progress using overlays
---
dired-async.el | 151 ++++++++++++++++++++++++++++++++------------------------
1 files changed, 86 insertions(+), 65 deletions(-)
diff --git a/dired-async.el b/dired-async.el
index b698911..fc2f65a 100644
--- a/dired-async.el
+++ b/dired-async.el
@@ -117,31 +117,46 @@
(defvar overwrite)
(defvar async-callback))
+(defmacro dired-async-wrap-call (file callback forms)
+ `(let ((overlay (dired-async-highlight-file ,file)))
+ ,(if callback
+ `(setq ,callback `(lambda (ret)
+ (dired-async-remove-highlight ,overlay)
+ (funcall ,,callback ret))))
+ ,forms))
+
+(put 'dired-async-wrap-call 'lisp-indent-function 2)
+
(defun dired-copy-file-recursive (from to ok-flag &optional
preserve-time top recursive)
(when (and (eq t (car (file-attributes from)))
(file-in-directory-p to from))
(error "Cannot copy `%s' into its subdirectory `%s'" from to))
(let ((attrs (file-attributes from))
- (callback `(lambda (&optional ignore)
- (dired-after-file-create ,to ,actual-marker-char
- ,overwrite))))
+ (callback (if (boundp 'actual-marker-char)
+ `(lambda (&optional ignore)
+ (dired-after-file-create ,to ,actual-marker-char
+ ,overwrite))
+ 'ignore)))
(if (and recursive
(eq t (car attrs))
(or (eq recursive 'always)
(yes-or-no-p (format "Recursive copies of %s? " from))))
;; This is a directory.
- (if (and dired-async-use-native-commands
- (not (file-remote-p from))
- (not (file-remote-p to)))
- (let ((args (list "-fR" from to)))
- (if preserve-time
- (setq args (cons "-p" args)))
- (unless ok-flag
- (setq args (cons "-n" args)))
- (async-start-process "cp" (executable-find "cp") callback args))
- (async-start (apply-partially #'copy-directory from to preserve-time)
- callback))
+ (dired-async-wrap-call from callback
+ (if (and dired-async-use-native-commands
+ (not (file-remote-p from))
+ (not (file-remote-p to)))
+ (let ((args (list "-fR" from to)))
+ (if preserve-time
+ (setq args (cons "-p" args)))
+ (unless ok-flag
+ (setq args (cons "-n" args)))
+ (apply #'async-start-process "cp" (executable-find "cp")
+ callback args))
+ (async-start (apply-partially #'copy-directory from to
+ preserve-time)
+ callback)))
;; Not a directory.
(or top (dired-handle-overwrite to))
(condition-case err
@@ -158,9 +173,10 @@
(setq args (cons "-n" args)))
(apply #'async-start-process "cp" (executable-find "cp")
callback args))
- (async-start (apply-partially #'copy-file from to ok-flag
- preserve-time)
- callback)))
+ (dired-async-wrap-call from callback
+ (async-start (apply-partially #'copy-file from to ok-flag
+ preserve-time)
+ callback))))
(file-date-error
(push (dired-make-relative from)
dired-create-files-failures)
@@ -169,19 +185,20 @@
(defun dired-rename-file (file newname ok-if-already-exists)
(dired-handle-overwrite newname)
(let ((callback
- `(lambda (&optional ignore)
- ;; Silently rename the visited file of any buffer visiting this
- ;; file.
- (and (get-file-buffer ,file)
- (with-current-buffer (get-file-buffer ,file)
- (set-visited-file-name ,newname nil t)))
- (dired-remove-file ,file)
- ;; See if it's an inserted subdir, and rename that, too.
- (dired-rename-subdir ,file ,newname)
+ (if (boundp 'actual-marker-char)
+ `(lambda (&optional ignore)
+ ;; Silently rename the visited file of any buffer visiting this
+ ;; file.
+ (and (get-file-buffer ,file)
+ (with-current-buffer (get-file-buffer ,file)
+ (set-visited-file-name ,newname nil t)))
+ (dired-remove-file ,file)
+ ;; See if it's an inserted subdir, and rename that, too.
+ (dired-rename-subdir ,file ,newname)
- (dired-after-file-create ,newname ,(and (boundp
'actual-marker-char)
- actual-marker-char)
- ,overwrite))))
+ (dired-after-file-create ,newname ,actual-marker-char
+ ,overwrite))
+ 'ignore)))
(if (and dired-async-use-native-commands
(not (file-remote-p file))
(not (file-remote-p newname)))
@@ -190,9 +207,10 @@
(setq args (cons "-n" args)))
(apply #'async-start-process "mv" (executable-find "mv")
callback args))
- (async-start (apply-partially #'rename-file file newname
- ok-if-already-exists)
- callback))))
+ (dired-async-wrap-call file callback
+ (async-start (apply-partially #'rename-file file newname
+ ok-if-already-exists)
+ callback)))))
(defun dired-delete-file (file &optional recursive trash) "\
Delete FILE or directory (possibly recursively if optional RECURSIVE is true.)
@@ -205,17 +223,18 @@ Anything else, ask for each sub-directory."
;; (and (file-directory-p fn) (not (file-symlink-p fn)))
;; but more efficient
(if (not (eq t (car (file-attributes file))))
- (cond
- ;; How to reliably trash files on other systems? Use Emacs to do it
- (trash
- (async-start-process "rmtrash" (executable-find "rmtrash")
- 'ignore "-f" file))
- ((and (not trash) dired-async-use-native-commands
- (not (file-remote-p file)))
- (async-start-process "rm" (executable-find "rm") 'ignore "-f" file))
- (t
- (async-start (apply-partially #'delete-file file trash)
- 'ignore)))
+ (dired-async-wrap-call file nil
+ (cond
+ ;; How to reliably trash files on other systems? Use Emacs to do it
+ (trash
+ (async-start-process "rmtrash" (executable-find "rmtrash")
+ 'ignore "-f" file))
+ ((and (not trash) dired-async-use-native-commands
+ (not (file-remote-p file)))
+ (async-start-process "rm" (executable-find "rm") 'ignore "-f" file))
+ (t
+ (async-start (apply-partially #'delete-file file trash)
+ 'ignore))))
(if (and recursive
(directory-files file t dired-re-no-dot) ; Not empty.
(or (eq recursive 'always)
@@ -227,18 +246,19 @@ Anything else, ask for each sub-directory."
(dired-make-relative file)))))
(if (eq recursive 'top) (setq recursive 'always)) ; Don't ask again.
(setq recursive nil))
- (if (and dired-async-use-native-commands
- (not (file-remote-p file)))
- (if recursive
- (if trash
- (async-start-process "rmtrash" (executable-find "rmtrash")
- 'ignore "-fr" file)
- (async-start-process "rm" (executable-find "rm")
- 'ignore "-fr" file))
- (async-start-process "rmdir" (executable-find "rmdir")
- 'ignore file))
- (async-start (apply-partially #'delete-directory file recursive trash)
- 'ignore))))
+ (dired-async-wrap-call file nil
+ (if (and dired-async-use-native-commands
+ (not (file-remote-p file)))
+ (if recursive
+ (if trash
+ (async-start-process "rmtrash" (executable-find "rmtrash")
+ 'ignore "-fr" file)
+ (async-start-process "rm" (executable-find "rm")
+ 'ignore "-fr" file))
+ (async-start-process "rmdir" (executable-find "rmdir")
+ 'ignore file))
+ (async-start (apply-partially #'delete-directory file recursive trash)
+ 'ignore)))))
(defun dired-create-files (file-creator operation fn-list name-constructor
&optional marker-char)
@@ -264,8 +284,8 @@ corresponding new file name or nil to skip.
Optional MARKER-CHAR is a character with which to mark every
newfile's entry, or t to use the current marker character if the
old file was marked."
- (let (dired-create-files-failures failures
- skipped (success-count 0) (total (length fn-list)))
+ (let (dired-create-files-failures
+ failures skipped (success-count 0) (total (length fn-list)))
(let (to overwrite-query
overwrite-backup-query) ; for dired-handle-overwrite
(dolist (from fn-list)
@@ -306,7 +326,8 @@ ESC or `q' to not overwrite any of the remaining files,
;; With the new behavior of `copy-directory'
;; (similar to the `cp' shell command) we don't
;; need such a construction of the target directory,
- ;; so modify the destination TO to "~/test/" instead of
"~/test/foo/".
+ ;; so modify the destination TO to "~/test/" instead of
+ ;; "~/test/foo/".
(let ((destname (file-name-directory to)))
(when (and (file-directory-p from)
(file-directory-p to)
@@ -332,21 +353,21 @@ ESC or `q' to not overwrite any of the remaining files,
(setq failures (nconc failures dired-create-files-failures))
(dired-log-summary
(format "%s failed for %d file%s in %d requests"
- operation (length failures)
- (dired-plural-s (length failures))
- total)
+ operation (length failures)
+ (dired-plural-s (length failures))
+ total)
failures))
(failures
(dired-log-summary
(format "%s failed for %d of %d file%s"
- operation (length failures)
- total (dired-plural-s total))
+ operation (length failures)
+ total (dired-plural-s total))
failures))
(skipped
(dired-log-summary
(format "%s: %d of %d file%s skipped"
- operation (length skipped) total
- (dired-plural-s total))
+ operation (length skipped) total
+ (dired-plural-s total))
skipped))
(t
(message "%s proceeding asynchronously..." operation)))))
- [elpa] master b7ec203 021/187: Fix for when async.el is byte-compiled, (continued)
- [elpa] master b7ec203 021/187: Fix for when async.el is byte-compiled, Michael Albinus, 2015/12/30
- [elpa] master 3f870f5 028/187: Show ops in progress `dired-async-in-process-face', Michael Albinus, 2015/12/30
- [elpa] master 1cec376 030/187: Added async-sandbox, Michael Albinus, 2015/12/30
- [elpa] master 24811ee 027/187: Show full backtraces if `async-debug' is non-nil, Michael Albinus, 2015/12/30
- [elpa] master 15f737f 032/187: Propagate non-zero exit codes as errors, Michael Albinus, 2015/12/30
- [elpa] master eda8d32 035/187: * helm-async.el (dired-create-file): Use quote., Michael Albinus, 2015/12/30
- [elpa] master ec1f0e8 034/187: * helm-async.el: let-bind dired-recursive-copies to 'always to avoid hanging on child., Michael Albinus, 2015/12/30
- [elpa] master acb0885 031/187: Several minor fixes, Michael Albinus, 2015/12/30
- [elpa] master 49f8b81 038/187: * helm-async.el: Update copyright, Michael Albinus, 2015/12/30
- [elpa] master 416c73a 037/187: * helm-async.el (helm-async-be-async): New, allow turning off async., Michael Albinus, 2015/12/30
- [elpa] master 2db438b 029/187: dired-async now shows progress using overlays,
Michael Albinus <=
- [elpa] master c472c4a 036/187: * helm-async.el Return file errors in child Emacs., Michael Albinus, 2015/12/30
- [elpa] master eb26295 033/187: * helm-async.el: New, redefine dired-create-file to work with helm and dired., Michael Albinus, 2015/12/30
- [elpa] master c35324c 043/187: Async queue handling has to happen in dired-async, Michael Albinus, 2015/12/30
- [elpa] master ac1b896 040/187: Minor touches, Michael Albinus, 2015/12/30
- [elpa] master ad07ff3 039/187: Merge pull request #1 from thierryvolpiatto/master, Michael Albinus, 2015/12/30
- [elpa] master 6941276 046/187: * helm-async.el (helm-async-processes): use process-name., Michael Albinus, 2015/12/30
- [elpa] master 1647b97 047/187: * async.el (async-start): Use the possible true name of emacs executable., Michael Albinus, 2015/12/30
- [elpa] master 9779abc 044/187: Fix github issue 2, Michael Albinus, 2015/12/30
- [elpa] master 96cbe3a 048/187: Fix missing optional arguments when calling `async-copy-file' in `async-dired.el'., Michael Albinus, 2015/12/30
- [elpa] master 819b936 045/187: * helm-async.el: Turn off mode-line notification only when last process end., Michael Albinus, 2015/12/30