branch: main
commit 551ffac1dc4669bb0c8a1879adc57de3a508af0d
Author: Yuri D. Lensky <ydl@Yuris-MacBook-Pro-2.local>
Commit: Ikumi Keita <ik...@ikumi.que.jp>

    Call texdoc asynchronously
    
    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.  Note
    we use the connection type `pipe' in case that PDFVIEWER environment
    variable is set to "evince %s &".
    
    Copyright-paperwork-exempt: yes
---
 tex.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tex.el b/tex.el
index b4643ee0..e2c33808 100644
--- a/tex.el
+++ b/tex.el
@@ -6626,12 +6626,20 @@ enter the number of the file to view, anything else to 
skip: ") list)))
                 (when (get-buffer-window buffer)
                   (quit-window t (get-buffer-window buffer)))))
           ;; Called without prefix argument:
-          ;; just run "texdoc --view <pkg>".
-          ;; 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)))))))
+          ;; just run "texdoc -I --view <pkg>".
+          (make-process
+           :name "texdoc"
+           :command (list "texdoc" "-I" "--view" pkg)
+           :sentinel (lambda (proc _string)
+                       ;; Recent Texdoc returns exit code 3 when it
+                       ;; can't find the specified document:
+                       ;; <URL:https://tug.org/texdoc/doc/texdoc.man1.pdf>
+                       (when (= (process-exit-status proc) 3)
+                         (message "No documentation found for %s" pkg)))
+           ;; Use pipe rather than pty for particular situations.  See
+           ;; <URL:https://lists.gnu.org/r/auctex/2024-09/msg00012.html>
+           ;; for detail.
+           :connection-type 'pipe))))))
 
 (defun TeX-goto-info-page ()
   "Read documentation for AUCTeX in the info system."

Reply via email to