GNU bug report logs - #73840
[PATCH] Improved folding for citations

Previous Next

Package: auctex;

Reported by: Paul Nelson <ultrono <at> gmail.com>

Date: Wed, 16 Oct 2024 20:01:01 UTC

Severity: normal

Tags: patch

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73840 in the body.
You can then email your comments to 73840 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Wed, 16 Oct 2024 20:01:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Nelson <ultrono <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Wed, 16 Oct 2024 20:01:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: bug-auctex <at> gnu.org
Subject: [PATCH] Improved folding for citations
Date: Wed, 16 Oct 2024 21:59:54 +0200
[Message part 1 (text/plain, inline)]
Hi again,

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

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.

Any feedback welcome.

Thanks, best,

Paul
[0001-Improved-folding-for-citations.patch (application/octet-stream, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Wed, 16 Oct 2024 20:31:01 GMT) Full text and rfc822 format available.

Message #8 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 73840 <at> debbugs.gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Wed, 16 Oct 2024 22:30:08 +0200
Paul Nelson <ultrono <at> gmail.com> 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




Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Thu, 17 Oct 2024 05:32:02 GMT) Full text and rfc822 format available.

Message #11 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: Arash Esbati <arash <at> gnu.org>
Cc: 73840 <at> debbugs.gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Thu, 17 Oct 2024 07:29:22 +0200
[Message part 1 (text/plain, inline)]
Hi Arash,

> 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.

OK, I did this with RefTeX (checking if it's bound and enabled).  For
bibtex.el, I just require'd it inside the internal function where it's
used.  I also implemented your correction to the docs.  Please find
attached the updated patch.  Any further feedback welcome.

Thanks, best,

Paul
[0001-Improved-folding-for-citations.patch (application/octet-stream, attachment)]

Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Mon, 21 Oct 2024 10:43:01 GMT) Full text and rfc822 format available.

Notification sent to Paul Nelson <ultrono <at> gmail.com>:
bug acknowledged by developer. (Mon, 21 Oct 2024 10:43:02 GMT) Full text and rfc822 format available.

Message #16 received at 73840-done <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 73840-done <at> debbugs.gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 12:42:02 +0200
Hi Paul,

Paul Nelson <ultrono <at> gmail.com> writes:

> OK, I did this with RefTeX (checking if it's bound and enabled).  For
> bibtex.el, I just require'd it inside the internal function where it's
> used.  I also implemented your correction to the docs.  Please find
> attached the updated patch.  Any further feedback welcome.

Many thank for this.  Installed, pushed and closing.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 15:27:02 GMT) Full text and rfc822 format available.

Message #19 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: ultrono <at> gmail.com
Cc: 73840 <at> debbugs.gnu.org, arash <at> gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Tue, 22 Oct 2024 00:25:54 +0900
Hi Paul,

>>>>> Arash Esbati <arash <at> gnu.org> writes:
> Paul Nelson <ultrono <at> gmail.com> writes:

>> OK, I did this with RefTeX (checking if it's bound and enabled).  For
>> bibtex.el, I just require'd it inside the internal function where it's
>> used.  I also implemented your correction to the docs.  Please find
>> attached the updated patch.  Any further feedback welcome.

Looking at your proposal again, a minor concern arose in my mind. The
new function `TeX-fold--bib-abbrev' can return nil, especially when
RefTeX isn't active. Then, let's look at this piece of code:
----------------------------------------------------------------------
(defun TeX-fold-cite-display (keys &rest _args)
[...]
  (let* (...
[...]
         (key-list (split-string keys "[ \f\t\n\r\v,]+"))
         (references
          (mapcar #'TeX-fold--bib-abbrev key-list))
         (joined-references (string-join references ", ")))
----------------------------------------------------------------------
This calls `TeX-fold--bib-abbrev' repeatedly on each element of
`key-list', so the result `references' can be a list of multiple `nil's.
In that case, `joined-references' seems to have unexpected form:

(let ((r (list nil nil nil)))
  (string-join r ", ")) --> ", , "

(However, maybe we should always turn on RefTeX in LaTeX mode buffers
and forget about usages without RefTeX. It wouldn't hurt after all,
since RefTeX is part of Emacs for quite a long period; I suppose there
are practically no users who don't activate RefTeX in AUCTeX LaTeX
mode.)

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW




Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 16:01:02 GMT) Full text and rfc822 format available.

Message #22 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: 73840 <at> debbugs.gnu.org, arash <at> gnu.org, ultrono <at> gmail.com
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 17:58:48 +0200
[Message part 1 (text/plain, inline)]
Hi Ikumi,

Thanks, you're totally right - my code did not correctly handle
citation failures when there are many citations.  Please take a look
at the attached patch.

Paul
[0001-Fix-improved-citation-folding-in-case-of-multiple-ba.patch (application/octet-stream, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 16:05:01 GMT) Full text and rfc822 format available.

Message #25 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: 73840 <at> debbugs.gnu.org, arash <at> gnu.org, ultrono <at> gmail.com
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 18:02:57 +0200
Also, just to respond to the second thing you said -- it's not
sufficient to enable reftex, because we need to handle the case that
someone enters citations that they have not yet added to their bib
files, (...).  In such cases, my code falls back to the "[c]" style
citation that we had before.




Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 17:35:02 GMT) Full text and rfc822 format available.

Message #28 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>, Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 73840 <at> debbugs.gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 19:33:27 +0200
Paul Nelson <ultrono <at> gmail.com> writes:

> Thanks, you're totally right - my code did not correctly handle
> citation failures when there are many citations.  Please take a look
> at the attached patch.

I'm not Keita, but we can't install this as is since `seq-keep' was
introduced with Emacs 29.1; we support Emacs 27+.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 17:41:02 GMT) Full text and rfc822 format available.

Message #31 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: Arash Esbati <arash <at> gnu.org>
Cc: Ikumi Keita <ikumi <at> ikumi.que.jp>, 73840 <at> debbugs.gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 19:39:10 +0200
[Message part 1 (text/plain, inline)]
> I'm not Keita, but we can't install this as is since `seq-keep' was
> introduced with Emacs 29.1; we support Emacs 27+.

Ah, right.  Please find attached, then.

(By the way, is there a linter to check for such things, or just manual?)
[0001-Fix-improved-citation-folding-in-case-of-multiple-ba.patch (application/octet-stream, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 18:06:01 GMT) Full text and rfc822 format available.

Message #34 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: 73840 <at> debbugs.gnu.org
Cc: ultrono <at> gmail.com
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 20:02:56 +0200
Hi Keita,

Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> (However, maybe we should always turn on RefTeX in LaTeX mode buffers
> and forget about usages without RefTeX. It wouldn't hurt after all,
> since RefTeX is part of Emacs for quite a long period; I suppose there
> are practically no users who don't activate RefTeX in AUCTeX LaTeX
> mode.)

While I tend to agree with your assessment reg. AUCTeX users and RefTeX
activation, I'd say AUCTeX shouldn't outsmart the users and require
RefTeX -- we'll never know which configuration users have.  Therefore, I
vote to stick to what we have.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#73840; Package auctex. (Mon, 21 Oct 2024 19:56:03 GMT) Full text and rfc822 format available.

Message #37 received at 73840 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: Ikumi Keita <ikumi <at> ikumi.que.jp>, 73840 <at> debbugs.gnu.org
Subject: Re: bug#73840: [PATCH] Improved folding for citations
Date: Mon, 21 Oct 2024 21:54:53 +0200
Paul Nelson <ultrono <at> gmail.com> writes:

> Ah, right.  Please find attached, then.

Thanks, installed.

> (By the way, is there a linter to check for such things, or just
> manual?)

I'm not sure if there is a linter.  Our usual process is that people
(mostly me) install all kind of stuff and Keita detects them by
compiling AUCTeX with older Emacs versions.  So I'd say it is manual,
AFAICT.  In this case, I checked the function manually.

Best, Arash




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 19 Nov 2024 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 212 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.