1

I know that I can disable the save query that comes after running TeX-run-TeX with LaTeX, TeX or actually probably any other NAME parameter (this is what happens when you invoke TeX-command-master, usually bound to C-c C-c, and then select LaTeX or TeX or whatever). I did disable it, but what this does, is automatically save, so I can't compile without saving, unless I re-enable the annoying save query, after which I can let it not save.

What I would ideally want, is that when invoking TeX-run-TeX with whatever option on its own it never saves (I would have to manually save), and TeX-command-run-all always saves.

In tex-buf.el, for me it looks like setting TeX-save-query to nil will definitely cause the file to be automatically saved, so it seems kind of annoying for me to solve this problem in a simple way.

2

The following advice makes TeX-check-files believe that no buffer is modified in TeX-command-master:

(defun ad-TeX-command-master-wo-check (fun &rest args)
  "Deactivates `buffer-modified-p` in `TeX-check-files'."
  (cl-letf* ((old-TeX-check-files (symbol-function 'TeX-check-files))
             ((symbol-function 'TeX-check-files)
               `(lambda (&rest args)
                  (cl-letf (((symbol-function 'buffer-modified-p) #'ignore))
                    (apply ,old-TeX-check-files args)))))
         (apply fun args)))


(advice-add 'TeX-command-master :around #'ad-TeX-command-master-wo-check)

You can use it with TeX-save-query on or off.

If TeX-save-query is on TeX-command-master does not save on compilation and TeX-command-run-all does save.

  • Thanks! This looked pretty good, but when I tried it out, compiling didn't do anything, or rather it probably recompiled the unedited file. Weird. – Berber Mar 12 at 14:00
  • @Berber Yes. Compiling the old code is exactly what you asked for. Maybe, you actually wanted to ask something different. – Tobias Mar 12 at 14:13
  • @Berber Perhaps you should just set "Command On" to Buffer and then type C-c C-c. You find that check box in the Command menu. – Tobias Mar 12 at 14:28
  • What I meant, was to compile the code in the buffer, without saving the code in the buffer to the file that is associated to the buffer. But now I see the problem: If I compile the master file, it will compile the old code, as it LaTeX reads the file, and not the buffer. So I guess what I ultimately want, which is to compile what is in the buffer, is not possible in this way. Especially if I invoked the command from a file that isn't the master file, the \input{file} line will obviously read a file, and never a buffer. Thank you very much for your code, it helped me understand things! – Berber Mar 12 at 14:37

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.