diff --git a/.travis.yml b/.travis.yml index cecf0ac..556e2b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ - evm install $EVM_EMACS --use --skip - cask env: - - EVM_EMACS=emacs-24.3-travis - EVM_EMACS=emacs-24.4-travis - EVM_EMACS=emacs-24.5-travis - EVM_EMACS=emacs-25.1-travis @@ -15,4 +14,4 @@ - make travis-ci after_script: - cat /tmp/undercover-report.json - - curl -v -include --form json_file=@/tmp/undercover-report.json https://coveralls.io/api/v1/jobs \ No newline at end of file + - curl -v -include --form json_file=@/tmp/undercover-report.json https://coveralls.io/api/v1/jobs diff --git a/README.ja.markdown b/README.ja.markdown index bf82545..d76f081 100644 --- a/README.ja.markdown +++ b/README.ja.markdown @@ -415,7 +415,7 @@ * args: コマンドの引数(可変長) * 返値:deferredオブジェクト * 外部コマンドを非同期で実行します。(start-process, start-process-shell-command のラッパー) - * 外部コマンドのstdoutの結果が文字列として後続のdeferredに渡ります。 + * 外部コマンドのstdoutとstderrの結果が文字列として後続のdeferredに渡ります。 * deferred:process-buffer (command args...) / deferred:process-shell-buffer (command args...) * 引数: @@ -423,7 +423,7 @@ * args: コマンドの引数(可変長) * 返値:deferredオブジェクト * 外部コマンドを非同期で実行します。(start-process, start-process-shell-command のラッパー) - * 外部コマンドのstdoutの結果がバッファとして後続のdeferredに渡ります。 + * 外部コマンドのstdoutとstderrの結果がバッファとして後続のdeferredに渡ります。 * バッファの処分は後続のdeferredに任されます。 * deferred:wait-idle (msec) diff --git a/README.markdown b/README.markdown index a7dfd8e..f4dbf46 100644 --- a/README.markdown +++ b/README.markdown @@ -459,7 +459,7 @@ * Return * a deferred object * Execute a command asynchronously. These functions are wrappers of `start-process` and `start-process-shell-command`. - * The subsequent deferred task receives the stdout from the command as a string. + * The subsequent deferred task receives the stdout and stderr from the command as a string. * deferred:process-buffer (command args...) / deferred:process-shell-buffer (command args...) * Arguments @@ -468,7 +468,7 @@ * Return * a deferred object * Execute a command asynchronously. These functions are wrappers of `start-process` and `start-process-shell-command`. - * The subsequent deferred task receives the stdout from the command as a buffer. + * The subsequent deferred task receives the stdout and stderr from the command as a buffer. * The following tasks are responsible to kill the buffer. * deferred:wait-idle (msec) diff --git a/deferred.el b/deferred.el index b8da8a7..179e05d 100644 --- a/deferred.el +++ b/deferred.el @@ -3,9 +3,9 @@ ;; Copyright (C) 2010-2016 SAKURAI Masashi ;; Author: SAKURAI Masashi -;; Version: 0.5.0 +;; Version: 0.5.1 ;; Keywords: deferred, async -;; Package-Requires: ((emacs "24.3")) +;; Package-Requires: ((emacs "24.4")) ;; URL: https://github.com/kiwanami/emacs-deferred ;; This program is free software; you can redistribute it and/or modify @@ -67,11 +67,12 @@ ;; deferred.el. (require 'cl-lib) +(require 'subr-x) (declare-function pp-display-expression 'pp) (defvar deferred:version nil "deferred.el version") -(setq deferred:version "0.4.0") +(setq deferred:version "0.5.0") ;;; Code: @@ -743,32 +744,32 @@ "A deferred wrapper of `start-process'. Return a deferred object. The process name and buffer name of the argument of the `start-process' are generated by this function automatically. -The next deferred object receives stdout string from the command -process." +The next deferred object receives stdout and stderr string from +the command process." (deferred:process-gen 'start-process command args)) (defun deferred:process-shell (command &rest args) "A deferred wrapper of `start-process-shell-command'. Return a deferred object. The process name and buffer name of the argument of the `start-process-shell-command' are generated by this function automatically. -The next deferred object receives stdout string from the command -process." +The next deferred object receives stdout and stderr string from +the command process." (deferred:process-gen 'start-process-shell-command command args)) (defun deferred:process-buffer (command &rest args) "A deferred wrapper of `start-process'. Return a deferred object. The process name and buffer name of the argument of the `start-process' are generated by this function automatically. -The next deferred object receives stdout buffer from the command -process." +The next deferred object receives stdout and stderr buffer from +the command process." (deferred:process-buffer-gen 'start-process command args)) (defun deferred:process-shell-buffer (command &rest args) "A deferred wrapper of `start-process-shell-command'. Return a deferred object. The process name and buffer name of the argument of the `start-process-shell-command' are generated by this function automatically. -The next deferred object receives stdout buffer from the command -process." +The next deferred object receives stdout and stderr buffer from +the command process." (deferred:process-buffer-gen 'start-process-shell-command command args)) (defun deferred:process-gen (f command args) @@ -807,25 +808,28 @@ (apply f proc-name buf-name command args))) (set-process-sentinel proc - (lambda (_proc event) - (cond - ((string-match "exited abnormally" event) - (let ((msg (if (buffer-live-p proc-buf) - (format "Process [%s] exited abnormally : %s" - command - (with-current-buffer proc-buf (buffer-string))) - (concat "Process exited abnormally: " proc-name)))) - (kill-buffer proc-buf) - (deferred:post-task nd 'ng msg))) - ((equal event "finished\n") - (deferred:post-task nd 'ok proc-buf))))) - (setf (deferred-cancel nd) - (lambda (x) (deferred:default-cancel x) - (when proc - (kill-process proc) - (kill-buffer proc-buf))))) - (error (deferred:post-task nd 'ng err))) - nil)) + (lambda (proc event) + (unless (process-live-p proc) + (if (zerop (process-exit-status proc)) + (deferred:post-task nd 'ok proc-buf) + (let ((msg (format "Deferred process exited abnormally:\n command: %s\n exit status: %s %s\n event: %s\n buffer contents: %S" + command + (process-status proc) + (process-exit-status proc) + (string-trim-right event) + (if (buffer-live-p proc-buf) + (with-current-buffer proc-buf + (buffer-string)) + "(unavailable)")))) + (kill-buffer proc-buf) + (deferred:post-task nd 'ng msg)))))) + (setf (deferred-cancel nd) + (lambda (x) (deferred:default-cancel x) + (when proc + (kill-process proc) + (kill-buffer proc-buf))))) + (error (deferred:post-task nd 'ng err))) + nil)) nd))) (defmacro deferred:processc (d command &rest args)