From 9f2efba8e677515e684e217e734df4ce7d4a3db0 Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <ydl@Yuris-MacBook-Pro-2.local>
Date: Mon, 30 Sep 2024 02:19:00 -0700
Subject: [PATCH] texdoc called non-interactively and synchronously

The older way of calling texdoc would hang emacs when the viewer_pdf was
emacsclient. Moreover, the intended way to send the error message
assumes texdoc is called non-interactively.

* tex.el: use `make-process` to call `texdoc` with `-I` argument.
---
 tex.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tex.el b/tex.el
index 93f2252..5448e94 100644
--- a/tex.el
+++ b/tex.el
@@ -6633,8 +6633,12 @@ enter the number of the file to view, anything else to skip: ") list)))
           ;; Recent Texdoc returns exit code 3 when it can't find the
           ;; specified document, according to
           ;; <URL:https://tug.org/texdoc/doc/texdoc.man1.pdf>
-          (if (= (call-process "texdoc" nil nil nil "--view" pkg) 3)
-              (message "No documentation found for %s" pkg)))))))
+          (make-process
+           :name "texdoc"
+           :command (list "texdoc" "-I" "--view" pkg)
+           :sentinel (lambda (proc string)
+                       (when (= (process-exit-status proc) 3)
+                         (message "No documentation found for %s" pkg)))))))))
 
 (defun TeX-goto-info-page ()
   "Read documentation for AUCTeX in the info system."
-- 
2.39.5 (Apple Git-154)

