Thanks for confirming. I think this patch is minor enough that I can push it and close the report (you don't have to do anything), although I'll wait another day or so in case there are other comments.
While we're at it, I noticed from the code in your first email that TeX-fold-cite-display is not flexible enough to reuse. It's tempting to move the main functionality to a helper function, TeX-fold-citation-raw in the attached patch, at which point we might as well just add the biblatex macros to the defaults. Any thoughts on this?
>From dfcbe80a6dcee7cc53257ac7526e52ed7fe9b1f9 Mon Sep 17 00:00:00 2001 From: Paul Nelson <[email protected]> Date: Sat, 26 Jul 2025 18:23:06 +0200 Subject: [PATCH] Add citation display functions for biblatex macros * tex-fold.el (TeX-fold-macro-spec-list): Add entries for textcite, parencite, and footcite macros. (TeX-fold-citation-raw): New function. (TeX-fold-cite-display): Refactor to use the above. (TeX-fold-textcite-display, TeX-fold-parencite-display) (TeX-fold-footcite-display): New functions. (bug79076) --- tex-fold.el | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/tex-fold.el b/tex-fold.el index 4daad455..5afa0ef5 100644 --- a/tex-fold.el +++ b/tex-fold.el @@ -75,6 +75,9 @@ macros, `math' for math macros and `comment' for comments." (defcustom TeX-fold-macro-spec-list '(("[f]" ("footnote" "marginpar")) (TeX-fold-cite-display ("cite")) + (TeX-fold-textcite-display ("textcite")) + (TeX-fold-parencite-display ("parencite")) + (TeX-fold-footcite-display ("footcite")) ("[l]" ("label")) ("[r]" ("ref" "pageref" "eqref" "footref")) ("[i]" ("index" "glossary")) @@ -842,11 +845,12 @@ contain the required information." (goto-char (point-min)) (TeX-fold--bib-abbrev-entry-at-point)))) -(defun TeX-fold-cite-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." +(defun TeX-fold-citation-raw (keys default) + "Helper function for fold displays for citation macros. +KEYS are the citation key(s), as a comma-delimited list. Return DEFAULT +unless we can find some of the citation keys, in which case return +string of the form \"XYZ99\", or a comma-delimited list of such, +followed by any optional citation string." (let* ((citation (car (TeX-fold-macro-nth-arg 1 (point) (TeX-fold-item-end (point) 'macro) @@ -854,12 +858,27 @@ using authors' last names and the the publication year." (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) + (concat (if (string-empty-p joined-references) + default + joined-references) (when citation - (format ", %s" citation)) - "]"))) + (format ", %s" citation))))) + +(defun TeX-fold-cite-display (keys &rest _args) + "Fold display for \\cite{KEYS} macro." + (concat "[" (TeX-fold-citation-raw keys "c") "]")) + +(defun TeX-fold-textcite-display (keys &rest _args) + "Fold display for \\textcite{KEYS} macro." + (TeX-fold-citation-raw keys "c")) + +(defun TeX-fold-parencite-display (keys &rest _args) + "Fold display for \\parencite{KEYS} macro." + (concat "(" (TeX-fold-citation-raw keys "c") ")" )) + +(defun TeX-fold-footcite-display (keys &rest _args) + "Fold display for \\footcite{KEYS} macro." + (concat "^" (TeX-fold-citation-raw keys "c"))) ;;; Utilities -- 2.39.3 (Apple Git-145)
_______________________________________________ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
