[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b80f1a5 018/187: Don't use pipes for communication just ye
From: |
Michael Albinus |
Subject: |
[elpa] master b80f1a5 018/187: Don't use pipes for communication just yet |
Date: |
Wed, 30 Dec 2015 11:49:26 +0000 |
branch: master
commit b80f1a58bd961a2aaa7857772e7fd08d100b71d4
Author: John Wiegley <address@hidden>
Commit: John Wiegley <address@hidden>
Don't use pipes for communication just yet
---
async.el | 65 +++++++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/async.el b/async.el
index 155f9bf..c0bc632 100644
--- a/async.el
+++ b/async.el
@@ -35,6 +35,8 @@
:group 'emacs)
(defvar async-debug nil)
+(defvar async-send-over-pipe nil)
+(defvar async-in-child-emacs nil)
(defvar async-callback nil)
(defvar async-callback-for-process nil)
(defvar async-callback-value nil)
@@ -68,12 +70,8 @@ as follows:
(or exclude-regexp "-syntax-table\\'")
(symbol-name sym))))
(let ((value (symbol-value sym)))
- (when (funcall (or predicate
- (lambda (sym)
- (let ((value (symbol-value sym)))
- (or (not (functionp value))
- (symbolp value)))))
- sym)
+ (when (or (null predicate)
+ (funcall predicate sym))
(setq bindings (cons `(quote ,value) bindings)
bindings (cons sym bindings)))))))
bindings)))
@@ -114,14 +112,35 @@ as follows:
(error "Async process '%s' failed with exit code %d"
(process-name proc) (process-exit-status proc))))))
+(defun async--receive-sexp (&optional stream)
+ (let ((sexp (read (base64-decode-string (read stream)))))
+ (if async-debug
+ (message "Received sexp {{{%s}}}" (pp-to-string sexp)))
+ (eval sexp)))
+
+(defun async--insert-sexp (sexp)
+ (prin1 sexp (current-buffer))
+ ;; Just in case the string we're sending might contain EOF
+ (base64-encode-region (point-min) (point-max) t)
+ (goto-char (point-min)) (insert ?\")
+ (goto-char (point-max)) (insert ?\" ?\n))
+
+(defun async--transmit-sexp (process sexp)
+ (with-temp-buffer
+ (if async-debug
+ (message "Transmitting sexp {{{%s}}}" (pp-to-string sexp)))
+ (async--insert-sexp sexp)
+ (process-send-region process (point-min) (point-max))))
+
(defun async-batch-invoke ()
"Called from the child Emacs process' command-line."
+ (setq async-in-child-emacs t)
(condition-case err
- (let ((sexp (read nil)))
- (if async-debug
- (message "Received sexp {{{%s}}}" (pp-to-string sexp)))
- (prin1 (funcall (eval sexp))))
+ (prin1 (funcall
+ (async--receive-sexp (unless async-send-over-pipe
+ command-line-args-left))))
(error
+ (backtrace)
(prin1 `(async-signal . ,err)))))
(defun async-ready (future)
@@ -211,18 +230,20 @@ returns nil. It can still be useful, however, as an
argument to
`async-ready' or `async-wait'."
(require 'find-func)
(let ((procvar (make-symbol "proc")))
- `(let ((,procvar
- (async-start-process "emacs" (expand-file-name invocation-name
-
invocation-directory)
- ,finish-func
- "-Q" "-l" ,(find-library-name "async")
- "-batch" "-f" "async-batch-invoke")))
- (with-temp-buffer
- (let ((print-escape-newlines t))
- (prin1 (list 'quote ,start-func) (current-buffer)))
- (insert ?\n)
- (process-send-region ,procvar (point-min) (point-max))
- (process-send-eof ,procvar))
+ `(let* ((sexp ,start-func)
+ (,procvar
+ (async-start-process
+ "emacs" (expand-file-name invocation-name
+ invocation-directory)
+ ,finish-func
+ "-Q" "-l" ,(find-library-name "async")
+ "-batch" "-f" "async-batch-invoke"
+ ,(and async-send-over-pipe
+ '(with-temp-buffer
+ (async--insert-sexp (list 'quote sexp))
+ (buffer-string))))))
+ ,(if async-send-over-pipe
+ `(async--transmit-sexp ,procvar (list 'quote sexp)))
,procvar)))
(defun async-test-1 ()
- [elpa] master 954c865 006/187: Updated README, (continued)
- [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
- [elpa] master 742c82e 020/187: Added message passing, but undocumented for now, Michael Albinus, 2015/12/30
- [elpa] master b80f1a5 018/187: Don't use pipes for communication just yet,
Michael Albinus <=
- [elpa] master 497e4da 024/187: Fix to dired-async for wdired-mode, Michael Albinus, 2015/12/30
- [elpa] master e08c251 017/187: Added `dired-async-use-native-commands', Michael Albinus, 2015/12/30
- [elpa] master 7ba4f40 022/187: Always base64 encode, Michael Albinus, 2015/12/30
- [elpa] master 1028235 023/187: Don't use lexical-binding in dired-async.el, Michael Albinus, 2015/12/30
- [elpa] master 12ca991 016/187: Made some macros into functions, added debug code, Michael Albinus, 2015/12/30
- [elpa] master 386a876 019/187: Some minor adjustments, Michael Albinus, 2015/12/30
- [elpa] master dfaddaa 025/187: Use pipes instead of variable passing, Michael Albinus, 2015/12/30
- [elpa] master d771dff 015/187: Added `async-start-process', Michael Albinus, 2015/12/30
- [elpa] master 66610f4 026/187: smtpmail-async: Report status to user when done, Michael Albinus, 2015/12/30
- [elpa] master b7ec203 021/187: Fix for when async.el is byte-compiled, Michael Albinus, 2015/12/30