I've run into a problem viewing pdf documentation files with AucTex. I use pdf-tools
to view PDF files from within Emacs, and I've set emacsclient -n
as my default pdf-viewer (via xdg-mime on Debian Linux). This works fine in most circumstances, but it breaks the (Tex-documentation-texdoc ...)
function of Auctex (C-c ?
).
I've narrowed the problem down to a single line of code. When I try to view the documentation for the listings
package, TeX-documentation-texdoc
turns this into the following sexp:
(shell-command-to-string "texdoc --view listings")
texdoc
in turn calls emacsclient
to actually open the file (based on how I've configured my desktop via xdg). However, at this point, the Emacs hangs and I need to quit (C-g
) to get control back. After that, no new pdf is opened. The same thing happens if I try to call emacsclient directly:
(shell-command-to-string "emacsclient -n tmp.pdf")
Both commands work at the command line (i.e., emacsclient -n tmp.pdf
and texdoc --view listings
.
My question is, in an instance like this, how do I call emacsclient from within Emacs? (and I know I could just open the pdf file with find-file
; that's not an option here as I need to call an external process (texdoc) to find the file, and that process then invokes emacsclient).
texdoc -M --list listings
to find the file, and then usefind-file
?texdoc --view
and then switching back to Emacs when it opens the file. But I think there should be a way to do this in a single step from Emacs?(async-shell-command "emacsclient -n tmp.pdf")
solve the problem?(async-shell-command "emacsclient -n tmp.pdf")
works, but not(async-shell-command "texdoc --view listings")
doesn't. So that's a useful clue.C-u C-c ?
work? It first shows the list of docs related to the package, then opens the viewer with(call-process "texdoc" nil 0 nil "--just-view" doc)
.