[Tex/LaTex] Creating a Keyboard Shortcut in Emacs for a Command in Auctex

auctexemacsreftex

I have created a custom command in the command list in Auctex. I want to be able to set it to a key binding like the View command which is C-c C-v. I know how to set global key bindings in the .emacs. I'm not sure how to do it for a custom command.

Here is the line I add into .emacs:

(add-to-list 'TeX-command-list'("Doall" "%`%l%(mode)%' %t; bibtex %s && %`%l%(mode)%' %t && %`%l%(mode)%' %t && %V" TeX-run-TeX t t :help "Run LaTeX BibTeX LaTeX LaTeX View"))

Any help on what to put after it to bind this to a key would be great.

Best Answer

You have to use TeX-command to call the command. It should look something like:

(add-hook 'LaTeX-mode-hook
          (lambda ()
             (local-set-key "\C-c\C-v"
                (lambda ()
                   (interactive)
                   (TeX-save-document (TeX-master-file))
                   (TeX-command "Doall" 'TeX-master-file' -1)))))

(untested)