I am trying to do the following:
is there a way/code that would let me know when the shell command has finished before starting a new elisp command from inside .emacs file?
@Francesco previously answered a similar question at the following link: https://stackoverflow.com/a/18707182/2112489
I discovered that using start-process
as a let-bound variable caused it to be run immediately, rather than waiting until the more desirable moment further on down in the function. I also discovered that set-process-sentinel
prevents using let-bound variables previously defined. Rather than using let-bound variables or global variables, another option would be to use a buffer-local variable -- e.g., (defvar my-local-variable nil "This is my local variable.") (make-variable-buffer-local 'my-local-variable)
-- and set it within the function -- e.g., (setq my-local-variable "hello-world")
. Although most examples that I have seen factor out the sentinel, I like to include everything into just one function -- e.g., such as the following snippet demonstrates:
(set-process-sentinel
(start-process
"my-process-name-one"
"*OUTPUT-BUFFER*"
"/path/to/executable"
"argument-one"
"argument-two"
"argument-three")
(lambda (p e) (when (= 0 (process-exit-status p))
(set-process-sentinel
(start-process
"my-process-name-two"
nil ;; example of not using an output buffer
"/path/to/executable"
"argument-one"
"argument-two"
"argument-three")
(lambda (p e) (when (= 0 (process-exit-status p))
(set-process-sentinel
(start-process . . . ))))))))