Yuri Lensky <[email protected]> writes:
> I would like to suggest the following patch, that fixes the use of
> texdoc in general, but especially when emacs itself is used as the PDF
> viewer. Please let me know if there is some more standard way (through
> git or otherwise) to make a pull request.
Thanks for the patch. We usually like patches generated with "git
format-patch", but we can deal with this one as well.
> 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.
Thanks for catching this. Indeed, this form
(let ((pkg "auctexomat"))
(if (= (call-process "texdoc" nil nil nil "--view" pkg) 3)
(message "No documentation found for %s" pkg)))
returns nil whereas this one returns the expected message:
(let ((pkg "auctexomat"))
(if (= (call-process "texdoc" nil nil nil "-I" "--view" pkg) 3)
(message "No documentation found for %s" pkg)))
I have only one question, though: Your patch turns the current
synchronous process (`call-process') into an asynchronous one
(`make-process'). I don't see a problem with this, but:
@Keita: You touched `TeX-documentation-texdoc', can you remember the
reason for `call-process'?
> * 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)
(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."
Best, Arash