2

I'm using Emacs with AUCTeX under Ubuntu 14.04. My frame is splitted into two windows like this:

 ------------------------------
|                |             |
|                |             |
|       1        |       2     |
|                |             |
|                |             |
 ------------------------------

Currently, C-c C-c only compiles the TeX file which is in window 1 and display errors (if any) in window 2.

I would like this command to automatically load the compiled pdf in window 2 if there isn't any error with the "docview".

By the way, I currently have to press "Enter" after invoking C-c C-c (in order to validate the fact I want to use my default compiler), is it possible to remove this validation part ?

I know I should modify my .emacs file, but I'm very uncomfortable with these configuration files...

  • 1
    Add this to your .emacs: (add-hook 'doc-view-mode-hook 'auto-revert-mode) With this activated, every time the underlying PDF is changed, DocView will auto-update the buffer. I've found it's a very useful setting to have, since DocView keeps your position in the file (even x–y positions on a page). You still have to find the file in Window 2, and I'm unsure as to how to hook onto a 'successful' run. – Sean Allred May 13 '14 at 18:29
  • @SeanAllred: I guess that advising the TeX-command-sentinel function would be the best idea. – mbork May 13 '14 at 18:56
  • 1
    @Sebastien: when you start using Emacs, eventually you'll learn Emacs Lisp;). It's kind of a slippery slope, but headed upwards, in the direction of the most powerful and elegant computer language in existence (I mean Lisp in general, not necessarily Emacs Lisp). – mbork May 13 '14 at 19:44
1

For your first question (it's a pity you didn't split the two!), I'd suggest advising the TeX-command-sentinel function. (I don't have enough time to investigate this now; the part where you want the log buffer to show the pdf after successful compilation might be a bit tricky, but definitely doable. The problem might be that window configurations in stock Emacs are rather volatile. There are some Emacs packages addressing that problem, but I don't know any of them. If anyone can solve this problem, feel free to edit this answer!)

For your second question (and you should really split them!), try e.g. this:

(define-key TeX-mode-map (kbd "C-c C-z")
  (lambda ()
    (interactive)
    (TeX-command TeX-command-default 'TeX-master-file)))

This might not be the most robust code ever (for instance, it can't compile the region), but it binds the (normally unused in AUCTeX) C-c C-z key sequence to running the default TeX command on current buffer's master file.

Surprisingly, calling the thing that C-c C-c would suggest is tricky: the command responsible for that is TeX-command-query, and it contains both the logic responsible for choosing the command to run and the interactive query. Very bad practice. One could either (a) copy-paste the first part of this function and change the last part or (b) advise this function so that the meaning of completing-read is temporarily changed (even worse practice!). (In fact, it would be best to file a feature request to AUCTeX developers to split this function in two! Speaking of splitting, this site works best if there's only one question per question.)

BTW, please don't use the .emacs file; it's better to use ~/.emacs.d/init.el.

BTW², did I mention that it would be best to split your two questions into two entries on this site?

0

I'd advise against doing this. Caring about "how it looks" distracts you from the contents. The advantage of (La)TeX is that it is foremost a system for organizing contents, the rendering for printing should be the last step.

  • In some circumstances, the syntax of the source code can distract you from the actual contents, where the compiled pdf is clean and readable (long equations, deep nesting of braces...). Another point is that some people like to compile and check that the output looks roughly OK as often as possible, to make debugging easier should a serious error appear. – T. Verron Jun 4 '14 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.