From e4757b4df676dc90cf497cfc8318ba0fe9b4d5af Mon Sep 17 00:00:00 2001 From: Arash Esbati Date: Mon, 7 Jul 2025 21:12:30 +0200 Subject: [PATCH] ; Fix last change * lisp/international/latexenc.el (latexenc-find-file-coding-system): Check if `TeX-master' is really set to a string globally. (AUCTeX bug#78841) (cherry picked from commit db46d5e8333e1eefcd7b3848d401f14d2bd7192f) --- lisp/international/latexenc.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lisp/international/latexenc.el b/lisp/international/latexenc.el index 1b735810ee4..19dec3a2ebb 100644 --- a/lisp/international/latexenc.el +++ b/lisp/international/latexenc.el @@ -150,18 +150,21 @@ coding system names is determined from `latex-inputenc-coding-alist'." (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 (and (bound-and-true-p TeX-master) + (stringp 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)) -- 2.39.5