Package list emacs-deferred / 2d9fc7e
Merge tag 'upstream/0.5.1' Upstream version 0.5.1 Lev Lamberov 4 years ago
4 changed file(s) with 39 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
44 - evm install $EVM_EMACS --use --skip
55 - cask
66 env:
7 - EVM_EMACS=emacs-24.3-travis
87 - EVM_EMACS=emacs-24.4-travis
98 - EVM_EMACS=emacs-24.5-travis
109 - EVM_EMACS=emacs-25.1-travis
1413 - make travis-ci
1514 after_script:
1615 - cat /tmp/undercover-report.json
17 - curl -v -include --form json_file=@/tmp/undercover-report.json https://coveralls.io/api/v1/jobs
16 - curl -v -include --form json_file=@/tmp/undercover-report.json https://coveralls.io/api/v1/jobs
414414 * args: コマンドの引数(可変長)
415415 * 返値:deferredオブジェクト
416416 * 外部コマンドを非同期で実行します。(start-process, start-process-shell-command のラッパー)
417 * 外部コマンドのstdoutの結果が文字列として後続のdeferredに渡ります。
417 * 外部コマンドのstdoutとstderrの結果が文字列として後続のdeferredに渡ります。
418418
419419 * deferred:process-buffer (command args...) / deferred:process-shell-buffer (command args...)
420420 * 引数:
422422 * args: コマンドの引数(可変長)
423423 * 返値:deferredオブジェクト
424424 * 外部コマンドを非同期で実行します。(start-process, start-process-shell-command のラッパー)
425 * 外部コマンドのstdoutの結果がバッファとして後続のdeferredに渡ります。
425 * 外部コマンドのstdoutとstderrの結果がバッファとして後続のdeferredに渡ります。
426426 * バッファの処分は後続のdeferredに任されます。
427427
428428 * deferred:wait-idle (msec)
458458 * Return
459459 * a deferred object
460460 * Execute a command asynchronously. These functions are wrappers of `start-process` and `start-process-shell-command`.
461 * The subsequent deferred task receives the stdout from the command as a string.
461 * The subsequent deferred task receives the stdout and stderr from the command as a string.
462462
463463 * deferred:process-buffer (command args...) / deferred:process-shell-buffer (command args...)
464464 * Arguments
467467 * Return
468468 * a deferred object
469469 * Execute a command asynchronously. These functions are wrappers of `start-process` and `start-process-shell-command`.
470 * The subsequent deferred task receives the stdout from the command as a buffer.
470 * The subsequent deferred task receives the stdout and stderr from the command as a buffer.
471471 * The following tasks are responsible to kill the buffer.
472472
473473 * deferred:wait-idle (msec)
22 ;; Copyright (C) 2010-2016 SAKURAI Masashi
33
44 ;; Author: SAKURAI Masashi <m.sakurai at kiwanami.net>
5 ;; Version: 0.5.0
5 ;; Version: 0.5.1
66 ;; Keywords: deferred, async
7 ;; Package-Requires: ((emacs "24.3"))
7 ;; Package-Requires: ((emacs "24.4"))
88 ;; URL: https://github.com/kiwanami/emacs-deferred
99
1010 ;; This program is free software; you can redistribute it and/or modify
6666 ;; deferred.el.
6767
6868 (require 'cl-lib)
69 (require 'subr-x)
6970
7071 (declare-function pp-display-expression 'pp)
7172
7273 (defvar deferred:version nil "deferred.el version")
73 (setq deferred:version "0.4.0")
74 (setq deferred:version "0.5.0")
7475
7576 ;;; Code:
7677
742743 "A deferred wrapper of `start-process'. Return a deferred
743744 object. The process name and buffer name of the argument of the
744745 `start-process' are generated by this function automatically.
745 The next deferred object receives stdout string from the command
746 process."
746 The next deferred object receives stdout and stderr string from
747 the command process."
747748 (deferred:process-gen 'start-process command args))
748749
749750 (defun deferred:process-shell (command &rest args)
750751 "A deferred wrapper of `start-process-shell-command'. Return a deferred
751752 object. The process name and buffer name of the argument of the
752753 `start-process-shell-command' are generated by this function automatically.
753 The next deferred object receives stdout string from the command
754 process."
754 The next deferred object receives stdout and stderr string from
755 the command process."
755756 (deferred:process-gen 'start-process-shell-command command args))
756757
757758 (defun deferred:process-buffer (command &rest args)
758759 "A deferred wrapper of `start-process'. Return a deferred
759760 object. The process name and buffer name of the argument of the
760761 `start-process' are generated by this function automatically.
761 The next deferred object receives stdout buffer from the command
762 process."
762 The next deferred object receives stdout and stderr buffer from
763 the command process."
763764 (deferred:process-buffer-gen 'start-process command args))
764765
765766 (defun deferred:process-shell-buffer (command &rest args)
766767 "A deferred wrapper of `start-process-shell-command'. Return a deferred
767768 object. The process name and buffer name of the argument of the
768769 `start-process-shell-command' are generated by this function automatically.
769 The next deferred object receives stdout buffer from the command
770 process."
770 The next deferred object receives stdout and stderr buffer from
771 the command process."
771772 (deferred:process-buffer-gen 'start-process-shell-command command args))
772773
773774 (defun deferred:process-gen (f command args)
806807 (apply f proc-name buf-name command args)))
807808 (set-process-sentinel
808809 proc
809 (lambda (_proc event)
810 (cond
811 ((string-match "exited abnormally" event)
812 (let ((msg (if (buffer-live-p proc-buf)
813 (format "Process [%s] exited abnormally : %s"
814 command
815 (with-current-buffer proc-buf (buffer-string)))
816 (concat "Process exited abnormally: " proc-name))))
817 (kill-buffer proc-buf)
818 (deferred:post-task nd 'ng msg)))
819 ((equal event "finished\n")
820 (deferred:post-task nd 'ok proc-buf)))))
821 (setf (deferred-cancel nd)
822 (lambda (x) (deferred:default-cancel x)
823 (when proc
824 (kill-process proc)
825 (kill-buffer proc-buf)))))
826 (error (deferred:post-task nd 'ng err)))
827 nil))
810 (lambda (proc event)
811 (unless (process-live-p proc)
812 (if (zerop (process-exit-status proc))
813 (deferred:post-task nd 'ok proc-buf)
814 (let ((msg (format "Deferred process exited abnormally:\n command: %s\n exit status: %s %s\n event: %s\n buffer contents: %S"
815 command
816 (process-status proc)
817 (process-exit-status proc)
818 (string-trim-right event)
819 (if (buffer-live-p proc-buf)
820 (with-current-buffer proc-buf
821 (buffer-string))
822 "(unavailable)"))))
823 (kill-buffer proc-buf)
824 (deferred:post-task nd 'ng msg))))))
825 (setf (deferred-cancel nd)
826 (lambda (x) (deferred:default-cancel x)
827 (when proc
828 (kill-process proc)
829 (kill-buffer proc-buf)))))
830 (error (deferred:post-task nd 'ng err)))
831 nil))
828832 nd)))
829833
830834 (defmacro deferred:processc (d command &rest args)