]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix last change
authorArash Esbati <arash@gnu.org>
Mon, 7 Jul 2025 19:12:30 +0000 (21:12 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 07:50:58 +0000 (09:50 +0200)
* 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

index 1b735810ee42a6e0241db1e6b391362fceaa8a65..19dec3a2ebb60b6623d6bb9d03b7b08a69df4c93 100644 (file)
@@ -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))