« Return to Thread: reftex-citation to complete from all citations instead of just ones used previously?

Re: reftex-citation to complete from all citations instead of just ones used previously?

by Michael Hoffman-7 :: Rate this Message:

| View in Thread

On 07/09/2012 04:45 PM, Michael Hoffman wrote:
> When I start AUCTeX there are no completions available for
> reftex-citation. I have to give it a regular expression first and then
> after selecting a citation it will be in the history for reftex-citation
> and also I can tab-complete to it in the prompt for reftex-citation.
>
> It seems like it would be easier to just tab out a citation key if I
> know its beginning and have the citations completed from the
> bibliography database instead of history. Is this possible?

I figured out how to do this, which I've described in response to a
question http://stackoverflow.com/a/11660493/494061 as well. I will copy
my response here:

The documentation of reftex-citation is a bit confusing. It promises
completion on known citation keys but I believe "known" refers to keys
that have been used previously in this session rather than all keys in
the appropriate bibliography. You can use the
LaTeX-add-all-bibitems-from-bibtex command defined below to load all
keys in your bibliography:

(defun get-bibtex-keys (file)
   (with-current-buffer (find-file-noselect file)
     (mapcar 'car (bibtex-parse-keys))))

(defun LaTeX-add-all-bibitems-from-bibtex ()
   (interactive)
   (mapc 'LaTeX-add-bibitems
         (apply 'append
                (mapcar 'get-bibtex-keys (reftex-get-bibfile-list)))))

Suggestions on appropriate hooks to make this happen automatically are
welcome.

Thanks!
Michael


_______________________________________________
auctex mailing list
auctex@...
https://lists.gnu.org/mailman/listinfo/auctex

 « Return to Thread: reftex-citation to complete from all citations instead of just ones used previously?