Subject: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex

From: Arash Esbati <[email-masked]>
Date: Sat, 13 Apr 2024 18:09:16 +0200

Hi Gustavo,

gusbrs <[email-masked]> writes:

> On Thu, 11 Apr 2024 at 12:46, Arash Esbati <[email-masked]> wrote:
>
> Just "someone" playing a little with this:
>
> (defun reftex-all-used-citation-keys-alt ()
>   (let* (keys)
>     (if (reftex-using-biblatex-p)
>         (let* ((master (reftex-TeX-master-file))
>                (bbl-file (file-name-with-extension master ".bbl")))
>           (when (file-exists-p bbl-file)
>             (with-temp-buffer
>               (insert-file-contents bbl-file)
>               (goto-char (point-min))
>               (while (re-search-forward "\\\\entry{\\([^}]*\\)}" nil t)
>                 (push (match-string-no-properties 1) keys)))))
>       (reftex-access-scan-info)
>       (let* ((files (reftex-all-document-files))
>              (aux-files (mapcar (lambda (x) (file-name-with-extension x ".aux"))
>                                 files))
>              file)
>         (while (setq file (pop aux-files))
>           (when (file-exists-p file)
>             (with-temp-buffer
>               (insert-file-contents file)
>               (goto-char (point-min))
>               (while (re-search-forward "^\\\\citation{\\([^}]*\\)}" nil t)
>                 (let ((key (match-string-no-properties 1)))
>                   (unless (member key keys)
>                     (push key keys)))))))))
>     (nreverse keys)))
>
> Quickly cooked, certainly needs polishing. But not a bad proof of
> concept, I think. Of course, this approach requires that the document
> has been compiled and the generated files are up to date with the main
> document.

Thanks, nice.  But I think the necessity you mention is also the weak
point of this approach: You can't just load a .tex file, run the caller
`reftex-create-bibtex-file' and close the file; you have to compile the
file.  So I don't think we should replace the current implementation
with the above.

>                   (unless (member key keys)
>                     (push key keys))

Can be written as:

  (cl-pushnew key keys :test #'string=)

Best, Arash