auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTEX] question: bibtex on separate files


From: Ralf Angeli
Subject: Re: [AUCTEX] question: bibtex on separate files
Date: Wed, 13 Feb 2008 19:03:59 +0100

* Guy Durrieu (2008-02-13) writes:

> I don't need so much! When using chapterbib (and the master being
> specified), the only thing one needs is, being within an included file,
> have the ability to run bibtex on that file just as if it was alone
> (i.e. some C-c C-b without any copy beforehand, I guess).

Now I understand.  This is a bit easier.  First you'll need an entry for
the list of commands accessible with `C-c C-c' which runs bibtex on the
current file.  You could customize `TeX-command-list' for this, but it
is better to leave the default value alone and just add an entry
programmatically.  Like this you don't have to worry about the value
when updating AUCTeX.  So here is the code for adding the entry:

     (add-to-list 'TeX-command-list
                  '("BibTeX (current file)" "bibtex %(buffile)" TeX-run-BibTeX
                    nil t :help "Run BibTeX on current file") t)

This will add the entry "BibTeX (current file)" to `TeX-command-list'.
When the entry is chosen through `C-c C-c', bibtex is called with an
argument computed by expanding "%(buffile)" and run through the filter
`TeX-run-BibTeX' which can parse the BibTeX output and make sense of
it for error messages.

So we obviously need some code expanding "%(buffile)".  Expanders can be
configured in `TeX-expand-list'.  Again, we will add an entry
programmatically instead of customizing it.  We need a function which
returns the file name accociated with the current buffer.  The name
should be stripped of the directory part and the extension.  Here is the
code to do all of this:

     (add-to-list 'TeX-expand-list
                  '("%(buffile)" (lambda ()
                                   (file-name-sans-extension
                                    (file-name-nondirectory
                                     (buffer-file-name))))) t)))

Since we can add the new entries to the variables mentioned above only
once they are defined we have to wrap both code snippets above into a
call to `eval-after-load'.  And with some assembly here is the full code
snippet you can paste into your init file.

(eval-after-load "tex"
  '(progn
     (add-to-list 'TeX-command-list
                  '("BibTeX (current file)" "bibtex %(buffile)" TeX-run-BibTeX
                    nil t :help "Run BibTeX on current file") t)
     (add-to-list 'TeX-expand-list
                  '("%(buffile)" (lambda ()
                                   (file-name-sans-extension
                                    (file-name-nondirectory
                                     (buffer-file-name))))) t)))

So when you restart Emacs and load a LaTeX file you should be able to
call `C-c C-c BibTeX <SPC> <TAB> <RET>' to call the new command.

-- 
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]