tom-tan/auctex-latexmk — pull request #11 by nealeyoung (2014-06-28 05:44:59+00:00)
Title: attempt to support latexmk -pvc mode. (just to show the idea, works for me, but should not be merged)

(from comments added in the file):

;; When run in -pvc mode, latexmk doesn't terminate when t is done
;; with the LaTeX processing. Instead it outputs the following string:
;;
;; === Watching for updated files. Use ctrl/C to stop ...
;;
;; and then watches the files that the process depends on. When one of
;; them changes, it starts another round, and repeats.
;;
;; As I understand it, the auctex system runs the latexmk process and
;; monitors it in two ways. First, the process has an elisp *process
;; filter* that is called whenever latexmk produces output. Second,
;; the process has a *sentinel* that is called when the latexmk process
;; terminates. Currently the process filter mostly just collects the
;; output in the compilation buffer, and when the process ends the sentinel
;; is called to report on the results to the user.
;;
;; But in -pvc mode the latexmk process doesn't terminate. We replace the
;; process filter with a function that first calls the regular process filter
;; then checks the buffer for the "=== Watching for .." string at the end.
;; If it finds that string, then it narrows the region to just the output
;; since the last run, then calls the sentinel directly on that portion.
;;
;; One issue is that the latexmk output is slightly different in -pvc mode,
;; so some of the strings that the sentinel looked for to parse the latexmk
;; output will not be there. I tried to patch the sentinel function below,
;; but I doubt I did it the right way.