Subject: bug#73840: [PATCH] Improved folding for citations

From: Arash Esbati <[email-masked]>
Date: Wed, 16 Oct 2024 22:30:08 +0200

Paul Nelson <[email-masked]> writes:

> I hope you're not too disappointed to hear that I only anticipate
> three further tex-fold.el patches.

Sad news, but hey, AUCTeX has also other files ;-)

> Citation macros \cite{...} are currently folded as [c].  This patch
> gives more descriptive folding when possible, using author names and
> publication years, like [Ne21] or [ABC99].  These are extracted from
> any bib files referenced in the document or specified by a user
> option.
>
> QUESTION: the new code uses reftex and bibtex.  Are we allowed to just
> require those in tex-fold.el?  I wasn't sure, since AUCTeX in general
> seems careful about (require) statements.

I didn't read the code carefuly, but Why can't we conditionalize this,
i.e., use RefTeX/BibTeX code if the libraries are loaded and plugged
into AUCTeX (RefTeX mainly), otherwise stick with what we have?  This is
actually AUCTeX mostly does.

>  doc/auctex.texi | 11 ++++++
>  tex-fold.el     | 96 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 106 insertions(+), 1 deletion(-)
>
> diff --git a/doc/auctex.texi b/doc/auctex.texi
> index 0356b96d..43d672d1 100644
> --- a/doc/auctex.texi
> +++ b/doc/auctex.texi
> @@ -2955,6 +2955,17 @@ specifications for @samp{begin} and @samp{end} from
>  @code{TeX-fold-macro-spec-list}.
>  @end defopt
>  
> +@defopt TeX-fold-bib-file
> +The default folding behavior for @samp{\cite{...@}} macros that point to a
                                               ^@{
> +BibTeX entry is to replace them with a string of the form [XYZ99], formed
> +using the authors' last names and the publication year.  If we cannot find
> +the required BibTeX entries in any bib files included in the current
> +document, then, as a backup, we search the files specified in
> +@code{TeX-fold-bib-file}.  This may be useful when using
> +@samp{\thebibliography{...@}} rather than BibTeX, or when working in
                         ^@{

Best, Arash