bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: gusbrs
Subject: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex
Date: Sat, 13 Apr 2024 08:59:00 -0300

Hi Arash,

On Thu, 11 Apr 2024 at 12:46, Arash Esbati <arash@gnu.org> wrote:

> I think AUCTeX/RefTeX are here, if we can improve them, we should do it.
> And if someone wants to replace it with something better, we can do it
> as well.  It is always a matter of "I need that", and best case is one
> implements that as well.

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.
(This is still tricked by biblatex's xdata, but I see no way around it
at this level).

Best,
gusbrs





reply via email to

[Prev in Thread] Current Thread [Next in Thread]