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

From: "Paul D. Nelson" <[email-masked]>
Date: Mon, 07 Jul 2025 19:30:47 +0200

Hi Arash,

> I installed my proposed change incl. comments from Stefan with commit
> 22daed7c.

With this commit, when I try to open any .tex file (existing or not), I
get "(wrong-type-argument sequencep t)" errors like those in the
attached backtrace (reproduced with emacs -Q).  My TeX-master value is
t.  The patch below seems to do the trick (but I'll confess that I
haven't studied the "big picture" here).

Paul

diff --git a/lisp/international/latexenc.el b/lisp/international/latexenc.el
index fea5be6dbd7..f7dd1452ca0 100644
--- a/lisp/international/latexenc.el
+++ b/lisp/international/latexenc.el
@@ -158,13 +158,14 @@ latexenc-find-file-coding-system
                               (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))))))
+                (when (stringp 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))