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
  • I've also posted this on StackOverflow, as I'm not sure where is more appropriate. Commented Nov 30, 2011 at 5:58
  • It might be nice to add links between the questions, particularly since they have different titles. Commented Dec 2, 2011 at 16:31
  • Link to SO qn: stackoverflow.com/questions/8321742/… Commented Nov 20, 2012 at 12:41

1 Answer 1

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.

4
  • Awesome! thanks. and thanks for all the details in your answer. Commented Dec 3, 2011 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. :-) Commented Dec 10, 2011 at 20:23
  • This does not add the command to the compile all (C-c C-a) sequence, does it?
    – tigre200
    Commented Oct 18, 2021 at 11:22
  • @tigre200, no it does not. For that I think you would need to add the custom sentinel function, but I haven't actually tried it. Commented Oct 21, 2021 at 4:13

You must log in to answer this question.

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