Extending list in .emacs init file

368 views Asked by At

I'm using Emacs with AUCTeX and I want to add a command to the TeX-command-list, namely makeglossaries. I refered to the manual and got this far:

(eval-after-load "tex"
  '(add-to-list 'TeX-command-list
       '("Makeglossaries" "makeglossaries %t" TeX-run-command nil
         (latex-mode)
         :help "Run makeglossaries script, which will choose xindy or makeindex") t))

However, when I execute this in emacs with C-c C-c I get

Running Makeglossaries' onnameOfFile' with ``makeglossaries nameOfFile.tex'' Don't pass the tex file to makeglossaries: either omit the extension to make all the glossaries, or specify one of the glossary files, e.g. nameOfFile.tex.glo, to make just that glossary.

The message is pretty clear. I somehow have to change %t so it omits the ".tex", however I don't know how to do that or where to look it up. Is this elisp code? Don't want to learn the language just for that.

Somebody knows how I can fix this problem?

Thanks it advance!

After a little more research I found I can replace %t with %s. %s apparently is the filename without extension, though I don't know where this is defined. Anyway this works for me:

(eval-after-load "tex"   '(add-to-list 'TeX-command-list
       '("Makeglossaries" "makeglossaries %s" TeX-run-command nil
         (latex-mode)
         :help "Run makeglossaries script, which will choose xindy or makeindex") t))
1

There are 1 answers

0
choroba On

Yes, that's elisp.

You can test for the extension with the following test:

(equal ".tex" (substring "file.tex" -4))

To remove it, use substring again:

(substring "file.tex" 0 -4)

Negative numbers count positions from the right.