[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8d27590 21/39: Finally handle the failures correctly.
From: |
Thierry Volpiatto |
Subject: |
[elpa] master 8d27590 21/39: Finally handle the failures correctly. |
Date: |
Wed, 18 May 2016 18:02:52 +0000 (UTC) |
branch: master
commit 8d27590ebaa916eeeeb10ec1697a52875d50d676
Author: Thierry Volpiatto <address@hidden>
Commit: Thierry Volpiatto <address@hidden>
Finally handle the failures correctly.
* dired-async.el (dired-async-operation): Removed no more needed.
(dired-async-failures): New face.
(dired-async-mode-line-message): Use one more arg FACE.
(dired-async-after-file-create): Handle failures.
(dired-async-create-files): Pass failures args to callback.
Remove code that is now never called since when the mode is turned off
and we are no more async the job is delegated again to old dired function.
---
dired-async.el | 56 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/dired-async.el b/dired-async.el
index 2da733a..a501466 100644
--- a/dired-async.el
+++ b/dired-async.el
@@ -44,7 +44,7 @@
(eval-when-compile
(defvar async-callback))
-(defvar dired-async-operation nil)
+;; (defvar dired-async-operation nil)
(defgroup dired-async nil
"Copy rename files asynchronously from dired."
@@ -72,6 +72,11 @@ Should take same args as `message'."
"Face used for mode-line message."
:group 'dired-async)
+(defface dired-async-failures
+ '((t (:foreground "red")))
+ "Face used for mode-line message."
+ :group 'dired-async)
+
(defface dired-async-mode-message
'((t (:foreground "Gold")))
"Face used for `dired-async--modeline-mode' lighter."
@@ -87,7 +92,7 @@ Should take same args as `message'."
(unless dired-async--modeline-mode
(let ((visible-bell t)) (ding))))
-(defun dired-async-mode-line-message (text &rest args)
+(defun dired-async-mode-line-message (text face &rest args)
"Notify end of operation in `mode-line'."
(message nil)
(let ((mode-line-format (concat
@@ -95,7 +100,7 @@ Should take same args as `message'."
(if args
(apply #'format text args)
text)
- 'face 'dired-async-message))))
+ 'face face))))
(force-mode-line-update)
(sit-for 3)
(force-mode-line-update)))
@@ -114,13 +119,13 @@ Should take same args as `message'."
(unless (> (length processes) 1)
(dired-async--modeline-mode -1))))
-(defun dired-async-after-file-create (len-flist)
+(defun dired-async-after-file-create (total operation failures skipped)
"Callback function used for operation handled by `dired-create-file'."
(unless (dired-async-processes)
;; Turn off mode-line notification
;; only when last process end.
(dired-async--modeline-mode -1))
- (when dired-async-operation
+ (when operation
(if (file-exists-p dired-async-log-file)
(progn
(pop-to-buffer (get-buffer-create "*dired async*"))
@@ -130,8 +135,25 @@ Should take same args as `message'."
(delete-file dired-async-log-file))
(run-with-timer
0.1 nil
- dired-async-message-function "Asynchronous %s of %s file(s) on %s
file(s) done"
- (car dired-async-operation) (cadr dired-async-operation) len-flist))))
+ (lambda ()
+ ;; First send error messages.
+ (cond (failures
+ (funcall dired-async-message-function
+ "%s failed for %d of %d file%s"
+ 'dired-async-failures
+ operation (length failures)
+ total (dired-plural-s total)))
+ (skipped
+ (funcall dired-async-message-function
+ "%s: %d of %d file%s skipped"
+ 'dired-async-failures
+ operation (length skipped) total
+ (dired-plural-s total))))
+ ;; Finally send the success message.
+ (funcall dired-async-message-function
+ "Asynchronous %s of %s file(s) on %s file(s) done"
+ 'dired-async-message
+ (car operation) (cadr operation) total))))))
(defun dired-async-maybe-kill-ftp ()
"Return a form to kill ftp process in child emacs."
@@ -150,7 +172,6 @@ Should take same args as `message'."
"Same as `dired-create-files' but asynchronous.
See `dired-create-files' for the behavior of arguments."
- (setq dired-async-operation nil)
(setq overwrite-query nil)
(let ((total (length fn-list))
failures async-fn-list skipped callback)
@@ -208,27 +229,16 @@ ESC or `q' to not overwrite any of the remaining files,
(dired-log "%s `%s' to `%s' failed"
operation from to)))
(push (cons from to) async-fn-list)))))
+ ;; Setup callback.
(setq callback
(lambda (&optional _ignore)
- (dired-async-after-file-create total)
+ (dired-async-after-file-create
+ total (list operation (length async-fn-list)) failures skipped)
(when (string= (downcase operation) "rename")
(cl-loop for (file . to) in async-fn-list
for bf = (get-file-buffer file)
do (and bf (with-current-buffer bf
(set-visited-file-name to nil t))))))))
- ;; Handle error happening in host emacs.
- (cond (failures
- (dired-log-summary
- (format "%s failed for %d of %d file%s"
- 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))
- skipped)))
;; Start async process.
(when async-fn-list
(async-start `(lambda ()
@@ -271,7 +281,7 @@ ESC or `q' to not overwrite any of the remaining files,
callback)
;; Run mode-line notifications while process running.
(dired-async--modeline-mode 1)
- (setq dired-async-operation (list operation (length async-fn-list)))
+ ;; (setq dired-async-operation (list operation (length async-fn-list)))
(message "%s proceeding asynchronously..." operation))))
(defadvice dired-create-files (around dired-async)
- [elpa] master e35506f 18/39: Remove unuseful code never called., (continued)
- [elpa] master e35506f 18/39: Remove unuseful code never called., Thierry Volpiatto, 2016/05/18
- [elpa] master af8933d 20/39: Unquote all callbacks., Thierry Volpiatto, 2016/05/18
- [elpa] master a48e509 28/39: Ensure a new line is added when printing to dired log buffer., Thierry Volpiatto, 2016/05/18
- [elpa] master 4d6efb9 25/39: Handle error also on host when async-list of file is empty., Thierry Volpiatto, 2016/05/18
- [elpa] master 8632abd 39/39: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs/elpa, Thierry Volpiatto, 2016/05/18
- [elpa] master 8d1a26d 29/39: Remove unused commented code., Thierry Volpiatto, 2016/05/18
- [elpa] master 228ec4b 34/39: Handle errors file by file instead of returning on first error., Thierry Volpiatto, 2016/05/18
- [elpa] master 0b8fbed 23/39: Remove commented line, no code change., Thierry Volpiatto, 2016/05/18
- [elpa] master 3ec3fb6 02/39: Declare package-alist in async-bytecomp.., Thierry Volpiatto, 2016/05/18
- [elpa] master dd77b81 22/39: Fix formatting the help form in dired-create-files., Thierry Volpiatto, 2016/05/18
- [elpa] master 8d27590 21/39: Finally handle the failures correctly.,
Thierry Volpiatto <=
- [elpa] master 1763517 14/39: Add comment no code change., Thierry Volpiatto, 2016/05/18
- [elpa] master 9a82294 26/39: DRY use apply., Thierry Volpiatto, 2016/05/18
- [elpa] master 1c57dc3 31/39: Better handling of errors happening on child., Thierry Volpiatto, 2016/05/18
- [elpa] master dd09794 33/39: Fix success message on callback., Thierry Volpiatto, 2016/05/18
- [elpa] master 14170a4 35/39: Add more info in mode-line on failures., Thierry Volpiatto, 2016/05/18
- [elpa] master 6e29e82 17/39: Switch to lexical-binding., Thierry Volpiatto, 2016/05/18
- [elpa] master 0e327f7 37/39: Update version number here too., Thierry Volpiatto, 2016/05/18
- [elpa] master 6521911 07/39: Merge pull request #59 from kolewu/kolewu-fix-typo-1, Thierry Volpiatto, 2016/05/18
- [elpa] master cd901e7 12/39: Improve backup-files by handling symlinks and time-stamp errors., Thierry Volpiatto, 2016/05/18
- [elpa] master e8db6cc 36/39: Update pkg file., Thierry Volpiatto, 2016/05/18