Hi all, To reproduce:
1. Enable auto-insert-mode, with auto-insert-query non-nil and some auto-insert-alist entry matching "\.tex\'". 2. Create a buffer running LaTeX-mode, but do not save it to a file. 3. Write a valid LaTeX document and run M-x preview-buffer. Emacs then asks you whether to perform TeX auto-insertion. This seems undesired and doesn't make much sense from a user POV. The issue is that in step 3, TeX-region-create attempts to visit the non-existent "<none>.tex", which runs find-file-hook, hence auto-insert. The attached patch binds auto-insert to nil around that visit. Any feedback welcome. I'll install it if there are no objections. Thanks, best, Paul
>From 0d5b9ed72c92dd5e1f1c61efcc21dc154a03a4e6 Mon Sep 17 00:00:00 2001 From: Paul Nelson <[email protected]> Date: Thu, 25 Jun 2026 14:46:10 +0200 Subject: [PATCH] Avoid auto-insert when visiting TeX master file * tex.el (auto-insert): Add defvar. (TeX-region-create): Bind auto-insert to nil while visiting the master file. --- tex.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tex.el b/tex.el index 9b3b8811..0b976cfe 100644 --- a/tex.el +++ b/tex.el @@ -99,6 +99,7 @@ (defvar TeX-ispell-verb-delimiters) ;; Others: (defvar tex--prettify-symbols-alist) ; tex-mode.el +(defvar auto-insert) ; autoinsert.el (defvar Info-file-list-for-emacs) ; info.el (defvar ispell-parser) ; ispell.el (defvar compilation-error-regexp-alist) ; compile.el @@ -9274,7 +9275,8 @@ original file." ;; We search for header and trailer in the master file. (orig-buffer (current-buffer)) (master-name (TeX-master-file TeX-default-extension)) - (master-buffer (find-file-noselect master-name)) + (master-buffer (let ((auto-insert nil)) + (find-file-noselect master-name))) ;; Attempt to disable font lock. (font-lock-mode-hook nil) -- 2.54.0
_______________________________________________ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
