8

I'm learning how to \usepackage{nomencl}. So far so good.

I added the nomenclature compile option to the Emacs commands by editing my .emacs file, adding:

;; nomenclature for latex
(eval-after-load "tex"
  '(add-to-list 'TeX-command-list 
        '("Nomenclature" "makeindex %s.nlo -s nomencl.ist -o %s.nls" TeX-run-command nil t :help "Create nomenclature file")))

to it, this works: when I press C-c C-c (the shortcut for TeX-command-list I can use the Nomenclature command and the appropriate file is generated. I am unhappy though, for the following reason:

When I run BibTeX, and then press C-c C-c again, Emacs offers to run LaTeX (as appropriate, and if references have changed, it will offer Command: (default) LaTeX again, finally, it will offer Command (default) View, once the .log doesn't report references have changed. When I run Nomeclature, the next command offered by Emacs is Command (default) View, which is always inappropriate.

How can I tell Emacs to default to LaTeX as the next TeX-command-list command after running Nomenclature (same behavior as BibTeX)?

3
9

The easiest way (that I know of) is to use a function in the place of TeX-run-command like:

;; nomenclature for latex
(eval-after-load "tex"
  '(add-to-list 'TeX-command-list 
                '("Nomenclature" "makeindex %s.nlo -s nomencl.ist -o %s.nls"
                  (lambda (name command file)
                    (TeX-run-compile name command file)
                    (TeX-process-set-variable file 'TeX-command-next TeX-command-default))
                  nil t :help "Create nomenclature file")))

You should use TeX-command-default instead of "LaTeX" since that will automatically choose between latex or plain tex etc. Note that I used TeX-run-compile instead of TeX-run-command since for some reason I couldn't get that to work.

You can also create a custom "sentinel" function which will check for errors etc. See TeX-BibTeX-sentinel as an example. This would allow you to conditionally change what the next command is based on whether there are errors etc. I don't think you have to, or even want to, do that in this case, but you can if you need to in the future.

3
  • Awesome! thanks. and thanks for all the details in your answer. Dec 3 '11 at 4:21
  • Thansk for asking this question and forcing me to finally fix my setup. I've had it partly broken for a long time now. :-) Dec 10 '11 at 20:23
  • This does not add the command to the compile all (C-c C-a) sequence, does it?
    – tigre200
    22 hours ago

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.