# Compile Latex without Saving, and without Query

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.

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)))


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.
• @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