In order to obtain more precise control over set-process-sentinel
| set-process-filter
| start-process
, one may wish to consider incorporating recursive-edit
to pause an elisp
function while a process is pending -- and either use exit-recursive-edit
or (throw 'exit nil)
to return control to the elisp
function that was paused.
EDIT (April 23, 2014): Redacted to create a minimal example incorporating recursive-edit
. A working example will be maintained and updated in a related thread: https://stackoverflow.com/a/23178396/2112489
(defun my-git-password-process-filter (proc string)
(when (string-match "password" string)
(process-send-string
proc
(concat (read-passwd "Password: ") "\n"))))
(defun my-process-sentinel (proc string)
(when (= 0 (process-exit-status proc))
(message "Process `%s` has finished pushing to `%s`." proc git-remote-name)
(throw 'exit nil)))
(defun example-using-recursive-edit ()
;;
;; For a more detailed working example, please see this related thread:
;; https://stackoverflow.com/a/23178396/2112489
;;
;; * * * REDACTED TO CREATE MINIMAL WORKING EXAMPLE * * *
;;
(set-process-sentinel
(start-process
"commit-all"
"*Messages*"
"/usr/local/git/bin/git"
"commit"
"-m"
git-commit-message)
(lambda (p e) (when (= 0 (process-exit-status p))
(mapcar (lambda (git-remote-name)
(let ((proc
(start-process
"push-process"
"*Messages*"
"/usr/local/git/bin/git"
"push"
"-v"
(format "%s" git-remote-name)
(format "%s"
(with-current-buffer (get-buffer "*REMOTES*")
git-branch-name)) )))
(set-process-filter proc 'my-git-password-process-filter)
(set-process-sentinel proc 'my-process-sentinel)
(recursive-edit) ))
(with-current-buffer (get-buffer "*REMOTES*")
git-remote-list) )))))