Subject: bug#34645: Make TeX-process-check prompt optional?

From: Arash Esbati <[email-masked]>
Date: Tue, 12 Mar 2024 21:15:23 +0100

Reuben Thomas <[email-masked]> writes:

> Yes, that looks good!

Thanks for your swift response.  My plan is to install the following
change (incl. addition to manual etc.).  Does it make sense to have the
custom variable settable on a per file basis or is it overkill?

--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index d53ef39b..f69c85ae 100644
--- a/tex.el
+++ b/tex.el
@@ -8769,22 +8769,31 @@ Return nil only if no process buffer exists."
           t)
       nil)))

+(defcustom TeX-kill-process-without-query nil
+  "If non-nil, abort a running document process without user query."
+  :group 'TeX-command
+  :type 'boolean
+  :local t
+  :safe #'booleanp)
+
 (defun TeX-process-check (name)
   "Check if a process for the TeX document NAME already exists.
 If so, give the user the choice of aborting the process or the current
-command."
+command.  If the value of `TeX-kill-process-without-query' is non-nil,
+user query is skipped and the process is aborted right away."
   (let (process)
     (while (and (setq process (TeX-process name))
                 (eq (process-status process) 'run))
       (cond
-       ((yes-or-no-p (concat "Process `"
-                             (process-name process)
-                             "' for document `"
-                             name
-                             "' running, kill it? "))
+       ((or TeX-kill-process-without-query
+            (yes-or-no-p (concat "Process `"
+                                 (process-name process)
+                                 "' for document `"
+                                 name
+                                 "' running, kill it? ")))
         (delete-process process))
        ((eq (process-status process) 'run)
-           (error "Cannot have two processes for the same document"))))))
+        (error "Cannot have two processes for the same document"))))))

 (defun TeX-process-buffer-name (name)
   "Return name of AUCTeX buffer associated with the document NAME."
--8<---------------cut here---------------end--------------->8---

> Thanks for looking at this old bug report.

You're welcome, and again sorry it took so long.

Best, Arash