Function: TeX-documentation-texdoc
TeX-documentation-texdoc is an interactive and byte-compiled function
defined in tex.el.
Signature
(TeX-documentation-texdoc &optional ARG)
Documentation
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.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
;;; Documentation
(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")
(if (not (executable-find "texdoc"))
(message "texdoc not found")
(let ((pkg (thing-at-point 'symbol t))
buffer list doc)
(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
(setq buffer (get-buffer-create (format "*texdoc: %s*" pkg)))
(erase-buffer)
(call-process "texdoc" nil t nil
"--list" "--nointeract" pkg)
(goto-char 1) ; No need to use `point-min' here.
(while (re-search-forward
"^ *\\([0-9]+\\) +\\([-~/a-zA-Z0-9_.${}#%,:\\ ()]+\\)"
nil t)
(push (cons (match-string 1) (match-string 2)) list)))
(unwind-protect
(cond
(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 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 -I --view <pkg>".
(make-process
:name "texdoc"
:command (list "texdoc" "-I" "--view" pkg)
:sentinel (lambda (proc _string)
;; Recent Texdoc returns exit code 3 when it
;; can't find the specified document:
;; <URL:https://tug.org/texdoc/doc/texdoc.man1.pdf>
(when (= (process-exit-status proc) 3)
(message "No documentation found for %s" pkg)))
;; Use pipe rather than pty for particular situations. See
;; <URL:https://lists.gnu.org/r/auctex/2024-09/msg00012.html>
;; for detail.
:connection-type 'pipe))))))