Emacs: if latexmk finishes okay, then show pdf, else display errors

前端 未结 1 1903
半阙折子戏
半阙折子戏 2020-12-20 06:42

Could anyone please give me hand with the step between the first start-process and the second start-process. The second

相关标签:
1条回答
  • 2020-12-20 07:33

    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)
    
    0 讨论(0)
提交回复
热议问题