Subject: Re: bug#40577: Auctex can't open anymore documentation

From: Ikumi Keita <[email-masked]>
Date: Mon, 13 Apr 2020 19:24:42 +0900

Hi Tobias,

>>>>> Tobias Bora <[email-masked]> writes:
> I don't know why, but I updated recently my .emacs file (which may
> downloaded a recent version of auctex), and since then I can't open
> documentation anymore. Indeed, if I do `C-c ? tikz <RET>` then okular
> starts, but is killed before opening the document. I tried with an empty
> configuration (emacs -Q) in a new home, and I even tried it on a
> completely empty (and new) user.

[...]

> Any idea what's going wrong? The only idea I have is that maybe emacs
> kills for some reason the okular process, but no idea why...

It may be related to my commit in 2018:
----------------------------------------------------------------------
commit c8a8d475d5a5c826c02313937e2bf09cca3fe057
Author: Ikumi Keita <[email-masked]>
Date:   Sun Nov 4 03:21:33 2018 +0900

    Don't block emacs during viewing document
    
    * tex.el (TeX-documentation-texdoc): Use asynchronous proces not to
    block emacs during viewing document.
    Supply "%s" to `message' argument in case the shell output contains
    accidental %-sequence.

diff --git a/tex.el b/tex.el
index 9995af3f..8f359246 100644
--- a/tex.el
+++ b/tex.el
@@ -6350,7 +6350,30 @@ the number of the file to view, anything else to skip: ")
 list)))
        ;; Called without prefix argument: just run "texdoc --view <pkg>" and
        ;; show the output, so that the user is warned in case it doesn't find
        ;; the documentation or "texdoc" is not available.
-       (message (shell-command-to-string (concat "texdoc --view " pkg)))))))
+       (message "%s"
+                ;; The folowing code to the end of `defun' used to be
+                ;; just
+                ;; (shell-command-to-string (concat "texdoc --view " pkg))
+                ;; , but in some cases it blocks emacs until the user
+                ;; quits the viewer (bug#28905).
+                (with-output-to-string
+                  (let* (;; Use pipe rather than pty because the
+                         ;; latter causes atril (evince variant
+                         ;; viewer) to exit before showing anything.
+                         (process-connection-type nil)
+                         (process (start-process-shell-command
+                                   "Doc view" standard-output
+                                   (concat "texdoc --view " pkg))))
+                    ;; Suppress the message "Process Doc view
+                    ;; finished".
+                    (set-process-sentinel process #'ignore)
+                    ;; Kill temp buffer without query.  This is
+                    ;; necessary, at least for some environment, if
+                    ;; the underlying shell can't find the texdoc
+                    ;; executable.
+                    (set-process-query-on-exit-flag process nil)
+                    ;; Don't discard shell output.
+                    (accept-process-output process))))))))
 
 (defun TeX-goto-info-page ()
   "Read documentation for AUCTeX in the info system."
----------------------------------------------------------------------
This commit is intended for evince but it might harm okular in some way.
Could you see whether your okular wokrs if you revert the above change?

Regards,
Ikumi Keita