Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

  1. 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).
  2. 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).
share|improve this question
    
Your question seems to me as odd as the 13. strike of a clock: not that is one strike to much, it rather indicates a deeper failure: When I'm writing a text, I compile early and often. After compiling for the first time, I open a pdfviewer, which does not block the PDF (Windows: SumatraPDF, Linux: whichever), and it stays open. Everytime latexmk compiles, the changes are displayed immediately. I'm using auto-save-buffers.el to make Emacs save every time I stop typing. So there is no need to have latexmk open a viewer after compiling each time?! –  Keks Dose Apr 2 at 20:26
    
@KeksDose: I hope I've answered your comment to your satisfaction. Generally speaking, "I do it another way" is not a valid argument; you need to argue "you're doing it wrong", but you don't have the elements for that. (Arguably, Skim might be broken, but even if it were fixed, which is easy, View will still jump to the current location.) –  Blaisorblade Apr 3 at 20:21
    
@Blaisorblade, can skim be asked to reload by sending it a signal? In the same way xdvi or xpdf can, because then it might be doable. You may need the help of the latexmk developer. –  daleif Apr 3 at 20:50
    
@Blaisorblade C-c C-v in Emacs usually makes the Viewer jump to the location of the curser, provided that you use synctex. But I was not aware of the limitations of skim you described. –  Keks Dose Apr 4 at 7:55
    
@KeksDose: yes, synctex is set up, but I'd just like a single command to do compile-and-jump. I also thought it would be easy in Emacs; but it might be easier in latexmk. –  Blaisorblade Apr 7 at 9:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.