branch: master
commit 242ae734273162f4ec027618610a099c9a73557b
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>
* helm-async.el: Fix error handling.
---
helm-async.el | 52 ++++++++++++++++++++++++++--------------------------
1 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/helm-async.el b/helm-async.el
index dc001a8..de5d88b 100644
--- a/helm-async.el
+++ b/helm-async.el
@@ -125,7 +125,7 @@ This allow to turn off async features provided to this
package."
(unless (> (length processes) 1)
(helm-async-mode -1))))
-(defun helm-async-after-file-create ()
+(defun helm-async-after-file-create (len-flist)
"Callback function used for operation handled by `dired-create-file'."
(unless (helm-async-processes)
;; Turn off mode-line notification
@@ -141,8 +141,8 @@ This allow to turn off async features provided to this
package."
(delete-file helm-async-log-file))
(run-with-timer
0.1 nil
- helm-async-message-function "Asynchronous %s of %s file(s) done"
- (car helm-async-operation) (cadr helm-async-operation)))))
+ helm-async-message-function "Asynchronous %s of %s file(s) on %s
file(s) done"
+ (car helm-async-operation) (cadr helm-async-operation) len-flist))))
(defun helm-async-maybe-kill-ftp ()
"Return a form to kill ftp process in child emacs."
@@ -182,8 +182,8 @@ old file was marked."
(setq helm-async-operation nil)
(let (dired-create-files-failures failures async-fn-list
skipped (success-count 0) (total (length fn-list))
- (callback '(lambda (&optional ignore)
- (helm-async-after-file-create))))
+ (callback `(lambda (&optional ignore)
+ (helm-async-after-file-create ,(length fn-list)))))
(let (to overwrite-query
overwrite-backup-query) ; for dired-handle-overwrite
(dolist (from fn-list)
@@ -263,19 +263,7 @@ ESC or `q' to not overwrite any of the remaining files,
failures)
(dired-log "%s `%s' to `%s' failed:\n%s\n"
operation from to err)))))))))
- (when (and async-fn-list helm-async-be-async)
- (async-start `(lambda ()
- (require 'cl) (require 'dired-aux)
- ,(async-inject-variables helm-async-env-variables-regexp)
- (condition-case err
- (let ((dired-recursive-copies (quote always)))
- (loop for (f . d) in (quote ,async-fn-list)
- do (funcall (quote ,file-creator) f d t)))
- (file-error
- (with-temp-file ,helm-async-log-file
- (insert (format "%S" err)))))
- ,(helm-async-maybe-kill-ftp))
- callback))
+ ;; Handle error happening in host emacs.
(cond
(dired-create-files-failures
(setq failures (nconc failures dired-create-files-failures))
@@ -297,14 +285,26 @@ ESC or `q' to not overwrite any of the remaining files,
operation (length skipped) total
(dired-plural-s total))
skipped))
- (t
- (if (and async-fn-list helm-async-be-async)
- (progn
- (helm-async-mode 1)
- (setq helm-async-operation (list operation (length fn-list)))
- (message "%s proceeding asynchronously..." operation))
- (message "%s: %s file%s"
- operation success-count (dired-plural-s success-count))))))
+ (t (message "%s: %s file%s"
+ operation success-count (dired-plural-s success-count))))
+ ;; Start async process.
+ (when (and async-fn-list helm-async-be-async)
+ (async-start `(lambda ()
+ (require 'cl) (require 'dired-aux)
+ ,(async-inject-variables helm-async-env-variables-regexp)
+ (condition-case err
+ (let ((dired-recursive-copies (quote always)))
+ (loop for (f . d) in (quote ,async-fn-list)
+ do (funcall (quote ,file-creator) f d t)))
+ (file-error
+ (with-temp-file ,helm-async-log-file
+ (insert (format "%S" err)))))
+ ,(helm-async-maybe-kill-ftp))
+ callback)
+ ;; Run mode-line notifications while process running.
+ (helm-async-mode 1)
+ (setq helm-async-operation (list operation (length async-fn-list)))
+ (message "%s proceeding asynchronously..." operation)))
(unless helm-async-be-async
(dired-move-to-filename)))