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.

  • Would C-c C-c d RET cut it for you? Once you add the custom command to your .emacs file, that would be all you need to do to run it. – Ricardo Aug 12 '11 at 1:23
  • @Ricardo - I guess that will cut it. Sometimes it asked me if 'Doall' for process 'master' do you want to kill it?? No why it would be doing this? I think it never stops running the view command. I am not sure why. Never had an issue when I ran the commands and view separately. – J Spen Aug 14 '11 at 4:18
  • @Ricardo - I got it sorted. Need to make it a && instead of a ; for some reason. I think that command wasn't getting killed. Not sure but thanks for the help. I would like if possible to use Rudiger solution. It didn't seem to work but not sure why. – J Spen Aug 14 '11 at 4:23

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 ()
                   (TeX-save-document (TeX-master-file))
                   (TeX-command "Doall" 'TeX-master-file' -1)))))


  • I couldn't get this working correctly. I understand the code but whenever I set it the key binding never worked. Thanks for the help.That's a good solution maybe eventually I'll get it going correctly. – J Spen Aug 14 '11 at 4:23

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.