GNU bug report logs - #78841
reftex-get-bibfile-list fails to detect biblatex if there's no buffer for the main file

Previous Next

Package: auctex;

Reported by: Tim Ruffing <dev <at> real-or-random.org>

Date: Thu, 19 Jun 2025 19:29:04 UTC

Severity: normal

Full log


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

From: Arash Esbati <arash <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Tim Ruffing <dev <at> real-or-random.org>, 78841 <at> debbugs.gnu.org,
 arne <at> arnested.dk
Subject: Re: bug#78841: reftex-get-bibfile-list fails to detect biblatex if
 there's no buffer for the main file
Date: Sun, 29 Jun 2025 11:34:25 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> LGTM.

Thanks.

> This said, I don't think we need `default-value`.  And we can
> presumably simplify the above to
>
>              (let ((file (if (re-search-forward
>                               "^%+ *\\(TeX-master\\|tex-main-file\\): *\"\\(.+\\)\""
>                               nil t)
>                              (match-string 2)
>                            (or (bound-and-true-p TeX-master)
>                                (bound-and-true-p tex-main-file)))))
>                (when (stringp file)
>                  (dolist ...)))

Yes, you're right.  And while we're at it, I also think we should
change:

  (search-forward "Local Variables:" nil t)

to

  (re-search-forward "^%+ *Local Variables:" nil t)

WDYT?  I'd install this change:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/international/latexenc.el b/lisp/international/latexenc.el
index 1b735810ee4..fea5be6dbd7 100644
--- a/lisp/international/latexenc.el
+++ b/lisp/international/latexenc.el
@@ -144,24 +144,27 @@ latexenc-find-file-coding-system
                                       (file-name-directory (nth 1 arg-list))
                                     default-directory))
                latexenc-main-file)
-            ;; Is there a TeX-master or tex-main-file in the local variables
-            ;; section?
+            ;; Is there a TeX-master or tex-main-file in the local
+            ;; variables section or is it globally set to a constant
+            ;; string?
             (unless latexenc-dont-use-TeX-master-flag
               (goto-char (point-max))
              (search-backward "\n\^L" (max (- (point-max) 3000) (point-min))
                                'move)
-             (search-forward "Local Variables:" nil t)
-              (when (re-search-forward
-                     "^%+ *\\(TeX-master\\|tex-main-file\\): *\"\\(.+\\)\""
-                     nil t)
-                (let ((file (match-string 2)))
-                  (dolist (ext `("" ,(if (boundp 'TeX-default-extension)
-                                         (concat "." TeX-default-extension)
-                                       "")
-                                 ".tex" ".ltx" ".dtx" ".drv"))
-                    (if (and (null latexenc-main-file) ;Stop at first.
-                             (file-exists-p (concat file ext)))
-                        (setq latexenc-main-file (concat file ext)))))))
+             (re-search-forward "^%+ *Local Variables:" nil t)
+              (let ((file (if (re-search-forward
+                               "^%+ *\\(TeX-master\\|tex-main-file\\): *\"\\(.+\\)\""
+                               nil t)
+                              (match-string 2)
+                            (or (bound-and-true-p TeX-master)
+                                (bound-and-true-p tex-main-file)))))
+                (dolist (ext `("" ,(if (boundp 'TeX-default-extension)
+                                       (concat "." TeX-default-extension)
+                                     "")
+                               ".tex" ".ltx" ".dtx" ".drv"))
+                  (if (and (null latexenc-main-file) ;Stop at first.
+                           (file-exists-p (concat file ext)))
+                      (setq latexenc-main-file (concat file ext))))))
             ;; try tex-modes tex-guess-main-file
             (when (and (not latexenc-dont-use-tex-guess-main-file-flag)
                        (not latexenc-main-file))
--8<---------------cut here---------------end--------------->8---

Best, Arash




This bug report was last modified 29 days ago.

Previous Next


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