Hi Greg, >>>>> Greg Bognar <greg.bog...@startmail.com> writes: > Your code works! So yes, your commit harmed okular in some way.
Thank you. That's a bad news for me :-) > Where do we go from here? Then we have to find out the way compatible for both okular and evince. Unfortunately, the old code is bad for evince; it still blocks emacs until the user quits evince as described in bug#28905[1]. [1] https://debbugs.gnu.org/28905 1. Can you please test the following code, then? This uses `start-process' instead of `start-process-shell-command', as suggested by Mosè in the thread of [1]. ---------------------------------------------------------------------- (defun TeX-documentation-texdoc (&optional arg) "Run texdoc to read documentation. Prompt for selection of the package of which to show the documentation. If called with a prefix argument ARG, after selecting the package, prompt for selection of the manual of that package to show." (interactive "P") (let ((pkg (thing-at-point 'symbol)) buffer list doc) ;; Strip off properties. XXX: XEmacs doesn't have ;; `substring-no-properties'. (set-text-properties 0 (length pkg) nil pkg) (setq pkg (TeX-read-string "View documentation for: " pkg)) (unless (zerop (length pkg)) (if arg ;; Called with prefix argument: run "texdoc --list --nointeract <pkg>" (progn ;; Create the buffer, insert the result of the command, and ;; accumulate the list of manuals. (with-current-buffer (get-buffer-create (setq buffer (format "*texdoc: %s*" pkg))) (erase-buffer) (insert (shell-command-to-string (concat "texdoc --list --nointeract " pkg))) (goto-char 1) ; No need to use `point-min' here. (save-excursion (while (re-search-forward ;; XXX: XEmacs doesn't support character classes in ;; regexps, like "[:alnum:]". "^ *\\([0-9]+\\) +\\([-~/a-zA-Z0-9_.${}#%,:\\ ()]+\\)" nil t) (push (cons (match-string 1) (match-string 2)) list)))) (unwind-protect (cond ((null (executable-find "texdoc")) ;; Note: `shell-command-to-string' uses shell, only ;; `call-process' looks at `exec-path', thus only here makes ;; sense to use `executable-find' to test whether texdoc is ;; available. (message "texdoc not found")) (list ;; Go on if there are manuals listed: show the buffer, prompt ;; for the number of the manual, then run ;; texdoc --just-view <doc> (TeX-pop-to-buffer (get-buffer buffer)) (condition-case nil (when (setq doc (cdr (assoc (TeX-read-string "Please enter \ the number of the file to view, anything else to skip: ") list))) (call-process "texdoc" nil 0 nil "--just-view" doc)) ;; Exit gently if a `quit' signal is thrown. (quit nil))) (t (message "No documentation found for %s" pkg))) ;; In any case quit-and-kill the window. (when (get-buffer-window buffer) (quit-window t (get-buffer-window buffer))))) ;; 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 "%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 "Doc view" standard-output "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)))))))) ---------------------------------------------------------------------- 2. If the above code fails, then could you provide the value of the following environment variables in the emacs shell (M-x shell)? That is, type "echo $PDFVIEWER RET" etc. in that shell. PDFVIEWER PDFVIEWER_texdoc TEXDOCVIEW_pdf TEXDOC_VIEWER_PDF I'd like to know whether there is something bad in your viewer setting to run inside emacs while safe in a vanilla shell. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine