Question 1: I would like to have a single key combo (C-c C-a) which compiles the file (with latexmk) and displays it.
This answer solves the first part.
I tried adapting the answer to also call TeX-view, as you see below (with some additional debugging code) but it does not work —
(TeX-active-master (TeX-output-extension)) is None at that point. Question 2: Why the heck? I'm a reasonable programmer, but I don't know enough Emacs Lisp to understand how that's possible. Is it a buffer local variable and we are in the wrong buffer? I ran out of time and hope reading the relevant AucTeX source code.
Moreover, the code should wait for latexmk, and apparently it does not, because TeX-command runs the external process asynchronously. How should I fix it?
Note: I've already tried the suggestion in this other answer, and it does not work.
(defun my-run-latex () (interactive) (let ((output-file (TeX-active-master (TeX-output-extension)))) (message output-file) ;Good. (TeX-save-document (TeX-master-file)) (TeX-command "LatexMk" 'TeX-master-file -1) (message (TeX-active-master (TeX-output-extension))) ; Bad ;(TeX-view) ;Won't work, because TeX-active-master does not work at this point. )
My AucTeX version is 11.87.3, on Emacs 24.3.1:
M-x emacs-version > GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org
Update: Why do I need to use the view command, instead of letting the viewer reload the file?
- The View command will also jump to the (clarified) location corresponding to the current location in the editor, while the PDF reload command will not. View (C-c C-v) does work with Skim (Skim provides a command for this purpose).
- My PDF viewer, Skim on OS X, does not reload the file automatically. I'm using one of the two setups recommended for Skim, the one where the reload is forced through the editor. I've just tried out the other one, and Skim asks whether to reload the file (it preserves the setting only until Skim is closed). I prefer to address this through Emacs than by changing Skim (unless you can show something at least as good as Skim in every respect).