Skip to content

Instantly share code, notes, and snippets.

@meliache
Last active February 3, 2023 19:23

Revisions

  1. meliache revised this gist Feb 3, 2023. No changes.
  2. meliache revised this gist Feb 3, 2023. No changes.
  3. meliache created this gist Feb 3, 2023.
    24 changes: 24 additions & 0 deletions texdoc.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    (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))