[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3d388c6 007/187: Added support for signal propagation
From: |
Michael Albinus |
Subject: |
[elpa] master 3d388c6 007/187: Added support for signal propagation |
Date: |
Wed, 30 Dec 2015 11:49:21 +0000 |
branch: master
commit 3d388c66816450ddd2afad520cf1f7bf9b1f3c74
Author: John Wiegley <address@hidden>
Commit: John Wiegley <address@hidden>
Added support for signal propagation
---
async.el | 50 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/async.el b/async.el
index 48cb59c..6b9dab2 100644
--- a/async.el
+++ b/async.el
@@ -81,12 +81,17 @@
(goto-char (point-max))
(backward-sexp)
(let ((result (read (current-buffer))))
- (if async-callback
- (prog1
- (funcall async-callback result)
- (kill-buffer (current-buffer)))
- (set (make-local-variable 'async-callback-value) result)
- (set (make-local-variable 'async-callback-value-set) t))))
+ (if (and (listp result)
+ (eq 'async-signal (car result)))
+ (if (eq 'error (car (cdr result)))
+ (error (cadr (cdr result)))
+ (apply #'signal (cdr result)))
+ (if async-callback
+ (prog1
+ (funcall async-callback result)
+ (kill-buffer (current-buffer)))
+ (set (make-local-variable 'async-callback-value) result)
+ (set (make-local-variable 'async-callback-value-set) t)))))
(set (make-local-variable 'async-callback-value) 'error)
(set (make-local-variable 'async-callback-value-set) t)
(error "Async Emacs process failed with exit code %d"
@@ -94,14 +99,12 @@
(defun async-batch-invoke ()
"Called from the child Emacs process' command-line."
- (with-temp-buffer
- (insert (nth 5 command-line-args))
- (goto-char (point-min))
- ;; Strip out the binding to `buf', as it is unreadable
- (while (re-search-forward "(buf \\. #<[^)]+)" nil t)
- (delete-region (match-beginning 0) (match-end 0)))
- (goto-char (point-min))
- (prin1 (funcall (eval (read (current-buffer)))))))
+ (condition-case err
+ (prin1 (funcall (eval (read (nth 5 command-line-args)))))
+ (signal
+ (prin1 `(async-signal . ,err)))
+ (error
+ (prin1 `(async-signal . ,err)))))
(defun async-get (proc)
"Wait until PROC has successfully completed."
@@ -167,7 +170,24 @@ ready to use it."
222))))
(message "I'm going to do some work here")
;; ....
- (message "Async process done, result should be 222: %s" (async-get proc))))
+ (message "Async process done, result should be 222: %s"
+ (async-get proc))))
+
+(defun async-test-3 ()
+ (interactive)
+ (message "Starting async-test-3...")
+ (async-start
+ ;; What to do in the child process
+ (lambda ()
+ (message "This is a test")
+ (sleep-for 3)
+ (error "Error in child process")
+ 222)
+
+ ;; What to do when it finishes
+ (lambda (result)
+ (message "Async process done, result should be 222: %s" result)))
+ (message "Starting async-test-1...done"))
(provide 'async)
- [elpa] master updated (e053cef -> ef4a542), Michael Albinus, 2015/12/30
- [elpa] master 6647749 002/187: Small change, Michael Albinus, 2015/12/30
- [elpa] master 8d37c00 004/187: Added note to README, Michael Albinus, 2015/12/30
- [elpa] master 4733d1e 001/187: Initial revision, Michael Albinus, 2015/12/30
- [elpa] master 3d388c6 007/187: Added support for signal propagation,
Michael Albinus <=
- [elpa] master 0a7f3dd 008/187: Added async-inject-environment, Michael Albinus, 2015/12/30
- [elpa] master 954c865 006/187: Updated README, Michael Albinus, 2015/12/30
- [elpa] master a8ac820 003/187: Renamed emacs-async.el to async.el, Michael Albinus, 2015/12/30
- [elpa] master 63fe7ee 010/187: Updated README, Michael Albinus, 2015/12/30
- [elpa] master c48d3db 009/187: Added smtpmail-async.el, Michael Albinus, 2015/12/30
- [elpa] master 728e791 005/187: Added dired-async, Michael Albinus, 2015/12/30
- [elpa] master 628a295 014/187: Send data over a pipe, rather than in an argument, Michael Albinus, 2015/12/30
- [elpa] master 190a040 012/187: Fixed async-smtpmail-send-it, Michael Albinus, 2015/12/30
- [elpa] master 4fb51ce 013/187: Corrected a problem with async deletions, Michael Albinus, 2015/12/30
- [elpa] master 1ad2902 011/187: Quiet byte-compiler warnings, Michael Albinus, 2015/12/30