Could anyone please give me hand with the step between the first start-process
and the second start-process
. The second
This answer provides a way to chain asynchronous commands, using sentinels to wait for each command to terminate before running the following.
You need to adapt the sentinel in order to check the process exit status using process-exit-status. A minimal working example for you should be along the lines of:
(defun run-latexmk ()
"Asynchronously run `latexmk' and attach a sentinel to it"
(let ((process (start-process "latexmk" "*output*"
"/bin/sh" "-c" "echo KO; false")))
(set-process-sentinel process 'latexmk-sentinel)))
(defun latexmk-sentinel (p e)
"Display the pdf if `latexmk' was successful"
(when (= 0 (process-exit-status p))
(start-process "displaypdf" "*output*"
"/bin/echo" "DISPLAY PDF")))
;; Example use
(with-current-buffer (get-buffer-create "*output*") (erase-buffer))
(run-latexmk)