So, perhaps you have already found the answer, if so I hope that you were planning to give it here and mark it ;). If not: the proces with which I would approach such a task is: find out in which keymap the bindings are which are already close to what you want; in this case: C-c C-a
. Simply ask about them with C-h k C-c C-a
You'll see it's in LaTeX-mode-map
.
So now you can do this:
(define-key LaTeX-mode-map (kbd "C-SPC")
(lambda ()
"Save the buffer and run `TeX-command-run-all`."
(interactive)
(save-buffer)
(TeX-command-run-all nil)))
Thanks by the way, I'm an evil user and I hadn't bothered, since the shortcut I had bound as an alternative for C-c C-a
was pretty convenient already. However not having to bother with pressing y RET
is definitely an improvement! ;)
[edit]
Tobias' comment below, provides the possibility to also save other documents/files that are part of the Tex master file. If that is what you prefer, use the following binding. There save-buffer
is replaced by TeX-save-document
. With the let
-binding of TeX-save-query
it saves modified buffers silently if they are part of the master document. If you want to be asked whether these files should be saved or not remove the let
-binding of TeX-save-query
.
(define-key LaTeX-mode-map (kbd "C-SPC")
(lambda ()
"Save the buffer and run `TeX-command-run-all`."
(interactive)
(let (TeX-save-query) (TeX-save-document (TeX-master-file)))
(TeX-command-run-all nil)))
C-SPC
. That key sequence is globally bound toset-mark-command
which is needed to select a region with the keyboard. Note, that theC-c C-a
key sequence of AucTeX is quite sensefully designed. The prefixC-c
starts major-mode related key sequences andC-c C-a
is a library binding standing for "all". I would suggest to bindC-c a
for your special command since that is one of the key sequences reserved for you as a user.