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

From: Ikumi Keita <[email-masked]>
Date: Tue, 22 Oct 2024 00:25:54 +0900

Hi Paul,

>>>>> Arash Esbati <[email-masked]> writes:
> Paul Nelson <[email-masked]> 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