15

I have just upgraded to AUCTeX 11.89.1 in emacs and find the new command (TeX-command-run-all) quite convenient. One problem is that after modifying the file and typing C-c C-a, confirmation is needed to save the file first.

I suspect that I kind of only need to set something to nil to deactivate this confirmation step, but I have not found a way. Any suggestions? Many thanks!

3
  • The file has to be saved. Do you mean to automatically save before running TeX-command-run-all?
    – jon
    Feb 4, 2016 at 6:50
  • @jon, yes, I want to save automatically on compiling. I think a short sequential lisp function would do, but i hope there is more direct way.
    – davyjones
    Feb 4, 2016 at 6:59
  • Related, possibly a duplicate. TeX-save-query is news to me, though :) How to omit comfirmation when I compile the files in emacs? Feb 4, 2016 at 12:57

3 Answers 3

20

The variable TeX-save-query controls this behavior:

User Option: TeX-save-query

If non-nil, then query the user before saving each file with TeX-save-document.

Add the following line to your init file

(setq TeX-save-query nil)
4
  • Is this a trap? If Emacs does not ask, the users will not save the file and TeX will run on the saved, old version?
    – Keks Dose
    Feb 4, 2016 at 9:47
  • 2
    It'll always save without asking, that's exactly what davyjones is looking after.
    – giordano
    Feb 4, 2016 at 9:48
  • OK, »my« solution works with all Emacs buffers, while this here is AUCTeX specific.
    – Keks Dose
    Feb 4, 2016 at 10:13
  • 5
    @KeksDose Which is exactly why it scares me :-) Feb 4, 2016 at 12:58
1

There is a lisp package, auto-save-buffers.el

Put into your .emacs:

(require 'auto-save-buffers)
(run-with-idle-timer 2 t 'auto-save-buffers)
(global-set-key [f8] 'auto-save-buffers-toggle)

»2«: seconds between stop typing and saving

»f8« toggle the function.

1
  • 6
    Unless you're always on some version control system, actually saving all the time seems like it could backfire on you pretty badly. Feb 4, 2016 at 12:58
0

Another approach would be to automatically save the buffer before evaluating TeX-command-run-all. The below simply adds a (save-buffer) prior to doing everything that the original TeX-command-run-all does, and then binds the new command over the original interactive key sequence.

(defun save-and-TeX-command-run-all (arg)
  (interactive "P")
  (save-buffer)
  (cond
   ((null arg)       (TeX-command-sequence t t))
   ((= 4 (car arg))  (TeX-command-run-all-region))
   (t                (LaTeX-command-run-all-section))))

(define-key LaTeX-mode-map (kbd "C-c C-a") 'save-and-TeX-command-run-all)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .