GNU bug report logs - #79076
14.1.0; TeX-fold-* folding \cite as "[c]"

Previous Next

Package: auctex;

Reported by: Kai Bagley <kaibagley <at> pm.me>

Date: Wed, 23 Jul 2025 07:27:02 UTC

Severity: normal

Found in version 14.1.0

To reply to this bug, email your comments to 79076 AT debbugs.gnu.org.

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#79076; Package auctex. (Wed, 23 Jul 2025 07:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kai Bagley <kaibagley <at> pm.me>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Wed, 23 Jul 2025 07:27:02 GMT) Full text and rfc822 format available.

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

From: Kai Bagley <kaibagley <at> pm.me>
To: "bug-auctex <at> gnu.org" <bug-auctex <at> gnu.org>
Subject: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Wed, 23 Jul 2025 07:25:45 +0000
[Message part 1 (text/plain, inline)]
Hello, thanks for maintaining this wonderful software

I am having an issue where TeX-fold-* functions will not fold my
~\cite~, ~\parencite~ and ~\textcite~ macros properly. They fold to
"[c]", "(c)" and "c" respectively.

For a brief period they worked (folded to "[authoryear]", "(authoryear)"
and "authoryear" respectively), but since then I can't seem to see
anything that might be interfering with it. Please see below for my
relevant AUCTeX config:

;; AUCTeX - TeX and LaTeX
(use-package auctex
:ensure '(auctex :repo "https://github.com/emacs-straight/auctex.git" ;; "https://git.savannah.gnu.org/git/auctex.git"
:branch "master"
:pre-build (("make" "elpa"))
:build (:not elpaca--compile-info)
:files ("*.el" "doc/*.info*" "etc" "images" "latex" "style")
:version (lambda () (require 'auctex) AUCTeX-version))
:init
(add-to-list 'auto-mode-alist '("\\.tex\\'" . LaTeX-mode))
(add-to-list 'major-mode-remap-alist '((latex-mode . LaTeX-mode)
(tex-mode . TeX-mode)))
:hook ((LaTeX-mode . electric-pair-mode)
(LaTeX-mode . visual-line-mode)
(LaTeX-mode . reftex-mode)
(LaTeX-mode . TeX-fold-mode))
:config
(add-hook 'find-file-hook #'TeX-fold-buffer)
;; Also fold parencite
(defun kb-TeX-fold-textcite-display (keys &rest _args)
"Fold display for a \\cite{KEYS} macro.
KEYS are the citation key(s), as a comma-delimited list. Return string
of the form \"[XYZ99]\" or \"[XYZ99, Optional Citation Text]\", formed
using authors' last names and the the publication year."
(let* ((citation (car (TeX-fold-macro-nth-arg
1 (point)
(TeX-fold-item-end (point) 'macro)
'(?\[ . ?\]))))
(key-list (split-string keys "[ \f\t\n\r\v,]+"))
(references (delq nil (mapcar #'TeX-fold--bib-abbrev key-list)))
(joined-references (string-join references ", ")))
(concat ""
(if (string-empty-p joined-references)
"c" joined-references)
(when citation
(format ", %s" citation))
"")))
(defun kb-TeX-fold-parencite-display (keys &rest _args)
"Fold display for a \\cite{KEYS} macro.
KEYS are the citation key(s), as a comma-delimited list. Return string
of the form \"[XYZ99]\" or \"[XYZ99, Optional Citation Text]\", formed
using authors' last names and the the publication year."
(let* ((citation (car (TeX-fold-macro-nth-arg
1 (point)
(TeX-fold-item-end (point) 'macro)
'(?\[ . ?\]))))
(key-list (split-string keys "[ \f\t\n\r\v,]+"))
(references (delq nil (mapcar #'TeX-fold--bib-abbrev key-list)))
(joined-references (string-join references ", ")))
(concat "("
(if (string-empty-p joined-references)
"c" joined-references)
(when citation
(format ", %s" citation))
")")))
(setq LaTeX-fold-macro-spec-list
`((kb-TeX-fold-parencite-display ("parencite"))
(kb-TeX-fold-textcite-display ("textcite"))))
:custom
;; Folding
(TeX-fold-auto t) ; Auto fold macros on insert
(TeX-outline-extra '(("[ \t]*\\\\\\(bib\\)?item\\b" 7)
("\\\\bibliography\\b" 2)))
(TeX-auto-save t)
(TeX-parse-self t)
(LaTeX-indent-level 4)
(LaTeX-item-indent 0))

Things I've tried:
- ~emacs -Q~ > ~package-install RET auctex RET~ > ~TeX-fold-mode~ >
~TeX-fold-buffer~
- Above but with the full above configuration
- Rerunning ~latex~, ~biber~, ~latexmk~ and all permutations of these
- ~edebug~ on ~TeX-fold-cite-display~, which reveals that
~TeX-fold-macro-nth-arg~ returns ~nil~ when evaluating ~TeX-fold-macro~
on a ~\cite~ macro.

Thank you for any help!
Kai

Emacs : GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0)
of 2025-07-21
Package: 14.1.0

current state:
==============
(setq
window-system 'pgtk
LaTeX-version "2e"
TeX-style-path '("~/.emacs.d/auctex/" "/home/289845i/.emacs.d/elpaca/builds/auctex/style"
"/home/289845i/.emacs.d/auctex/auto" "/home/289845i/.emacs.d/auctex/style" "auto" "style")
TeX-auto-save t
TeX-parse-self t
TeX-master t
TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t"
TeX-run-TeX nil (plain-TeX-mode AmSTeX-mode Texinfo-mode) :help "Run plain TeX")
("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (LaTeX-mode docTeX-mode) :help "Run LaTeX")
("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil (Texinfo-mode) :help
"Run Makeinfo with Info output")
("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" TeX-run-compile nil (Texinfo-mode)
:help "Run Makeinfo with HTML output")
("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t" TeX-run-TeX nil
(AmSTeX-mode) :help "Run AMSTeX")
("ConTeXt" "%(cntxcom) --once %(extraopts) %(execopts)%t" TeX-run-TeX nil (ConTeXt-mode) :help
"Run ConTeXt once")
("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil (ConTeXt-mode) :help
"Run ConTeXt until completion")
("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode ConTeXt-mode) :help
"Run BibTeX")
("Biber" "biber %(output-dir) %s" TeX-run-Biber nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run Biber")
("Texindex" "texindex %s.??" TeX-run-command nil (Texinfo-mode) :help "Run Texindex")
("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil (Texinfo-mode) :help
"Run Texi2dvi or Texi2pdf")
("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
("Print" "%p" TeX-run-command t t :help "Print the file")
("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible
TeX-queue-command)
("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Generate PostScript file")
("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Convert DVI file to PostScript")
("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Convert DVI file to PDF with dvipdfmx")
("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Convert PostScript file to PDF")
("LaTeXMk"
"latexmk %(latexmk-out) %(file-line-error) %(output-dir) %`%(extraopts) %S%(mode)%' %t"
TeX-run-TeX nil (LaTeX-mode docTeX-mode) :help "Run LaTeXMk")
("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Run makeglossaries to create glossary file")
("Index" "makeindex %(O?idx)" TeX-run-index nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Run makeindex to create index file")
("upMendex" "upmendex %(O?idx)" TeX-run-index t
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Run upmendex to create index file")
("Xindy" "texindy %s" TeX-run-command nil
(plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help
"Run xindy to create index file")
("Check" "lacheck %s" TeX-run-compile nil (LaTeX-mode) :help "Check LaTeX file for correctness")
("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (LaTeX-mode) :help
"Check LaTeX file for common mistakes")
("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document")
("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files")
("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
"Delete generated intermediate and output files")
("Other" "" TeX-run-command t t :help "Run an arbitrary command"))
)
[Message part 2 (text/html, inline)]

Information forwarded to bug-auctex <at> gnu.org:
bug#79076; Package auctex. (Wed, 23 Jul 2025 08:40:02 GMT) Full text and rfc822 format available.

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

From: Paul Nelson <ultrono <at> gmail.com>
To: Kai Bagley <kaibagley <at> pm.me>
Cc: 79076 <at> debbugs.gnu.org
Subject: Re: bug#79076: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Wed, 23 Jul 2025 10:38:56 +0200
[Message part 1 (text/plain, inline)]
Hi Kai,

On Wed, 23 Jul 2025 at 09:29, Kai Bagley via bug-auctex via Bug reporting
list for AUCTeX <bug-auctex <at> gnu.org> wrote:

>
> - ~edebug~ on ~TeX-fold-cite-display~, which reveals that
> ~TeX-fold-macro-nth-arg~ returns ~nil~ when evaluating ~TeX-fold-macro~
> on a ~\cite~ macro.
>

The call to TeX-fold-macro-nth-arg is used only for optional arguments.
Could you check what happens in the later parts of TeX-fold-cite-display,
particularly key-list and references?

Thanks, best,

Paul

>
[Message part 2 (text/html, inline)]

Information forwarded to bug-auctex <at> gnu.org:
bug#79076; Package auctex. (Wed, 23 Jul 2025 09:32:02 GMT) Full text and rfc822 format available.

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

From: Paul Nelson <ultrono <at> gmail.com>
To: Kai Bagley <kaibagley <at> pm.me>
Cc: 79076 <at> debbugs.gnu.org
Subject: Re: bug#79076: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Wed, 23 Jul 2025 11:30:46 +0200
[Message part 1 (text/plain, inline)]
(Please cc the bug tracker)

On Wed, 23 Jul 2025 at 11:04, Kai Bagley <kaibagley <at> pm.me> wrote:

>
> On Wednesday, July 23rd, 2025 at 4:39 PM, Paul Nelson <ultrono <at> gmail.com>
> wrote:
>
> Hi Kai,
>
> On Wed, 23 Jul 2025 at 09:29, Kai Bagley via bug-auctex via Bug reporting
> list for AUCTeX <bug-auctex <at> gnu.org> wrote:
>
>>
>> - ~edebug~ on ~TeX-fold-cite-display~, which reveals that
>> ~TeX-fold-macro-nth-arg~ returns ~nil~ when evaluating ~TeX-fold-macro~
>> on a ~\cite~ macro.
>>
>
> The call to TeX-fold-macro-nth-arg is used only for optional arguments.
> Could you check what happens in the later parts of TeX-fold-cite-display,
> particularly key-list
>
>
> The key-list gets set to (#("<citationkey>" 0 48 (fontified t face
> (font-lock-constant-face))))​
>
>
> and references?
>
>
> references gets set to nil​, the mapcar​ call returns nil​. Since that
> uses TeX-fold--bib-abbrev, I know that TeX-fold-bib-file is set to the
> correct bibliography file.
>
>
> Thanks, best,
>
> Paul
>
>
The key-list doesn’t sound correct. Could you please share the tex code
you’re trying to fold, and also check the value of the KEYS argument?
[Message part 2 (text/html, inline)]

Information forwarded to bug-auctex <at> gnu.org:
bug#79076; Package auctex. (Wed, 23 Jul 2025 11:37:01 GMT) Full text and rfc822 format available.

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

From: Kai Bagley <kaibagley <at> pm.me>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 79076 <at> debbugs.gnu.org
Subject: Re: bug#79076: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Wed, 23 Jul 2025 11:36:43 +0000
On Wednesday, July 23rd, 2025 at 5:30 PM, Paul Nelson <ultrono <at> gmail.com> wrote:

> (Please cc the bug tracker)
> 
> On Wed, 23 Jul 2025 at 11:04, Kai Bagley <kaibagley <at> pm.me> wrote:
> 
> > 
> > 
> > On Wednesday, July 23rd, 2025 at 4:39 PM, Paul Nelson <ultrono <at> gmail.com> wrote:
> > 
> > > Hi Kai,
> > > 
> > > On Wed, 23 Jul 2025 at 09:29, Kai Bagley via bug-auctex via Bug reporting list for AUCTeX <bug-auctex <at> gnu.org> wrote:
> > > 
> > > > 
> > > > - ~edebug~ on ~TeX-fold-cite-display~, which reveals that
> > > > ~TeX-fold-macro-nth-arg~ returns ~nil~ when evaluating ~TeX-fold-macro~
> > > > on a ~\cite~ macro.
> > > 
> > > 
> > > The call to TeX-fold-macro-nth-arg is used only for optional arguments. Could you check what happens in the later parts of TeX-fold-cite-display, particularly key-list
> > 
> > 
> > The key-list gets set to (#("<citationkey>" 0 48 (fontified t face (font-lock-constant-face))))
> > 
> > 
> > > 
> > > 
> > > and references?
> > > 
> > 
> > 
> > references gets set to nil, the mapcar call returns nil. Since that uses TeX-fold--bib-abbrev, I know that TeX-fold-bib-file is set to the correct bibliography file.
> > 
> > 
> > > 
> > > Thanks, best,
> > > 
> > > Paul
> 
> 
> The key-list doesn’t sound correct. Could you please share the tex code you’re trying to fold, and also check the value of the KEYS argument?

After keys is set, and getting it's value from the messages buffer after running edebug-eval-expression RET keys RET:

#("fathurahmanGeographicallyWeightedMultivariate2020" 0 49 (face (font-lock-constant-face) fontified t))

This is with LaTeX macro \cite{fathurahmanGeographicallyWeightedMultivariate2020}

Inserted using reftex-citation, which is using the file bib.bib, containing:

@article{fathurahmanGeographicallyWeightedMultivariate2020,
  title = {Geographically {{Weighted Multivariate Logistic Regression Model}} and {{Its Application}}},
  author = {Fathurahman, M. and {Purhadi} and {Sutikno} and Ratnasari, Vita},
  date = {2020},
  journaltitle = {Abstract and Applied Analysis},
  volume = {2020},
  number = {1},
  pages = {8353481},
  issn = {1687-0409},
  doi = {10.1155/2020/8353481},
  url = {https://onlinelibrary.wiley.com/doi/abs/10.1155/2020/8353481},
  urldate = {2024-07-29},
  abstract = {<shortened>},
  langid = {english},
  file = {<removed>}
}

I'm very unfamiliar with edebug, and probably emacs in general compared to you guys. If there's a better way to figure this out please let me know




Information forwarded to bug-auctex <at> gnu.org:
bug#79076; Package auctex. (Wed, 23 Jul 2025 15:13:02 GMT) Full text and rfc822 format available.

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

From: Paul Nelson <ultrono <at> gmail.com>
To: Kai Bagley <kaibagley <at> pm.me>
Cc: 79076 <at> debbugs.gnu.org
Subject: Re: bug#79076: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Wed, 23 Jul 2025 17:12:32 +0200
[Message part 1 (text/plain, inline)]
On Wed, 23 Jul 2025 at 13:36, Kai Bagley <kaibagley <at> pm.me> wrote:

>
> After keys is set, and getting it's value from the messages buffer after
> running edebug-eval-expression RET keys RET:
>
> #("fathurahmanGeographicallyWeightedMultivariate2020" 0 49 (face
> (font-lock-constant-face) fontified t))
>
> This is with LaTeX macro
> \cite{fathurahmanGeographicallyWeightedMultivariate2020}



I assume the citation name doesn’t have a newline, and what I see here is
just formatting from your mail client? If there’s really a newline, then
the folding won’t work.

My next question is whether TeX-fold—bib-abbrev gets called with the
expected citation name. You can see this by instrumenting that function
with edebug. The default bond in edebug is “e” for inspecting variables.
Please let me know if that function gets called and what the “key” argument
is. This will determine whether we need to understand what happens in that
function or in its caller.
[Message part 2 (text/html, inline)]

Information forwarded to bug-auctex <at> gnu.org:
bug#79076; Package auctex. (Thu, 24 Jul 2025 03:51:02 GMT) Full text and rfc822 format available.

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

From: Kai Bagley <kaibagley <at> pm.me>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 79076 <at> debbugs.gnu.org
Subject: Re: bug#79076: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Thu, 24 Jul 2025 03:50:06 +0000
On Wednesday, 23 July 2025 at 23:12, Paul Nelson <ultrono <at> gmail.com> wrote:

> On Wed, 23 Jul 2025 at 13:36, Kai Bagley <kaibagley <at> pm.me> wrote:
>
> >
> > After keys is set, and getting it's value from the messages buffer after running edebug-eval-expression RET keys RET:
> >
> > #("fathurahmanGeographicallyWeightedMultivariate2020" 0 49 (face (font-lock-constant-face) fontified t))
> >
> > This is with LaTeX macro \cite{fathurahmanGeographicallyWeightedMultivariate2020}
>
>
>
> I assume the citation name doesn’t have a newline, and what I see here is just formatting from your mail client? If there’s really a newline, then the folding won’t work.

It must be my client (proton mail web), but I don't see the newline so i may not be able to prevent it happening, sorry!

>
> My next question is whether TeX-fold—bib-abbrev gets called with the expected citation name. You can see this by instrumenting that function with edebug. The default bond in edebug is “e” for inspecting variables. Please let me know if that function gets called and what the “key” argument is. This will determine whether we need to understand what happens in that function or in its caller.

Alright I must have swapped to biblatex format at some stage from bibtex... I'm using Zotero with betterbibtex extension, and automatic updates on the file.

When TeX-fold--bib-abbrev-entry-at-point is called from TeX-fold--bib-abbrev, it tries to find the "year" field, but biblatex appears to prefer the "date" over "year", so Zotero at some point updated the file accordingly and stopped the function working (it exits the when-let* when year becomes nil). Deleting the bib file and recreating with Zotero as a better bibtex file solves the problem completely.

Is there a way to set tex-fold to use biblatex fields? I know there's a bibtex-dialect that can be set to biblatex, however TeX-fold--bib-abbrev-entry-at-point evaluates specifically (year (bibtex-text-in-field "year" entry)).




Information forwarded to bug-auctex <at> gnu.org:
bug#79076; Package auctex. (Thu, 24 Jul 2025 15:10:03 GMT) Full text and rfc822 format available.

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

From: Paul Nelson <ultrono <at> gmail.com>
To: Kai Bagley <kaibagley <at> pm.me>
Cc: 79076 <at> debbugs.gnu.org
Subject: Re: bug#79076: 14.1.0; TeX-fold-* folding \cite as "[c]"
Date: Thu, 24 Jul 2025 17:08:57 +0200
[Message part 1 (text/plain, inline)]
On Thu, 24 Jul 2025 at 05:50, Kai Bagley <kaibagley <at> pm.me> wrote:

>
> When TeX-fold--bib-abbrev-entry-at-point is called from
> TeX-fold--bib-abbrev, it tries to find the "year" field, but biblatex
> appears to prefer the "date" over "year", so Zotero at some point updated
> the file accordingly and stopped the function working (it exits the
> when-let* when year becomes nil). Deleting the bib file and recreating with
> Zotero as a better bibtex file solves the problem completely.
>
> Is there a way to set tex-fold to use biblatex fields? I know there's a
> bibtex-dialect that can be set to biblatex, however
> TeX-fold--bib-abbrev-entry-at-point evaluates specifically (year
> (bibtex-text-in-field "year" entry)).


> Not at the moment, but I assume this should be easy if the formats are
similar enough, although I’m not familiar with biblatex.  Could you please
share a working example, eg, small sample tex and bib files?
[Message part 2 (text/html, inline)]

This bug report was last modified today.

Previous Next


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