Last active
February 3, 2023 19:23
-
-
Save meliache/e645bf50c6aeac8e6e58b92c6bddac20 to your computer and use it in GitHub Desktop.
# LaTeX package documentation via `texdoc` with `completing-read` support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-get-texlive-package-list () | |
(let ((tlpdb-fpath (file-name-concat | |
(string-trim-right | |
(shell-command-to-string "kpsewhich -var-value TEXMFROOT")) | |
"tlpkg/texlive.tlpdb")) | |
(name-regex "^name \\([^ \n.]+\\)$")) | |
(with-current-buffer (find-file-noselect tlpdb-fpath 'nowarn 'rawfile) | |
(save-excursion | |
(goto-char (point-min)) | |
(cl-loop | |
while (re-search-forward name-regex nil 'noerror) | |
collect (match-string-no-properties 1)))))) | |
;; simpler alternative to `TeX-documentation-texdoc' which adds completing-read. | |
(defun my-texdoc (pkg) | |
"Show TeX documentation for package PKG. | |
If called interactively, select package from TexLive with interactive completion." | |
(interactive | |
(list (completing-read | |
"texdoc: " | |
(my-get-texlive-package-list) | |
nil nil nil | |
'my-texdoc-history))) | |
(call-process "texdoc" nil " *texdoc*" nil "--view" pkg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment