Subject: bug#28905: 11.90.2.2017-07-25; TeX-documentation-texdoc blocks

From: Mosè Giordano <[email-masked]>
Date: Sun, 22 Oct 2017 19:25:35 +0200

Hi Keita,

2017-10-22 15:13 GMT+02:00 Ikumi Keita <[email-masked]>:
> Hi Fran and Mosè,
>
>>>>>> Mosè Giordano <[email-masked]> writes:
>> Hi Fran,
>> 2017-10-19 23:38 GMT+02:00 Fran Burstall (Gmail) <[email-masked]>:
>>> Greetings!
>>>
>>> I do
>>>
>>> M-x TeX-documentation-texdoc
>>>
>>> and supply the argument amsmath when prompted.  An evince
>>> window fires with the documentation but emacs is blocked
>>> until I exit evince.
>>>
>>> If I try the same thing with tex-doc, evince fires but emacs
>>> remains usable.
>>>
>>> Experiment suggests that the former uses
>>> shell-command-to-string and this blocks while the latter
>
>> That's true, but I can't reproduce your issue.
>
> Fran's problem reproduces on my machine.  The output of
> TeX-sumit-bug-report is at the tail of this message.
>
>>  What happens if you run
>
>>     texdoc amsmath
>
>> in your terminal?  For me the viewer is opened in the background, so
>> the shell is free and the prompt readily appears, without waiting for
>> the viewer to be closed.  Isn't this the case for you?
>
> My result is the same as Fran's, too.  On my kterm (xterm variant
> capable of dealing with Japanese texts), the viewer is opened in the
> background, the shell is free and the prompt readily appears, without
> waiting for the viewer to be closed.
>
> It doesn't help to change the part
> (concat "texdoc --view " pkg)
> in `TeX-documentation-texdoc' to
> (concat "exec texdoc --view " pkg " &")
> for my case.  It seems that emacs grabs something of the subprocess of
> the shell and does not release it until all(?) of subprocess terminate.

Thanks for sharing your experience.  The problem with texdoc program
is that it doesn't use return status in a meaningful way.  There is no
way to know if it was able to find a documentation for the requested
package besides reading the output.  Try this:

    $ texdoc foobar
    Sorry, no documentation found for foobar.
    If you are unsure about the name, try searching CTAN's TeX catalogue at
    http://ctan.org/search.html#byDescription.
    $ echo $?
    0

Fran, as a workaround you can bind `TeX-doc' to C-c ? with

    (with-eval-after-load "tex"
      (define-key TeX-mode-map (kbd "C-c ?") 'TeX-doc))

even if I'd like to find a solution to keep `TeX-documentation-texdoc' working.

Bye,
Mosè