Skip to content

Instantly share code, notes, and snippets.

@vermiculus
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vermiculus/b48f68d46827b9a4b8ac to your computer and use it in GitHub Desktop.
Save vermiculus/b48f68d46827b9a4b8ac to your computer and use it in GitHub Desktop.
(defun TeX-find-texdoc (texdoc-query)
(interactive "sPackage: ")
(if (string-equal texdoc-query "")
(error "Cannot query texdoc against an empty string")
(let ((texdoc-output (shell-command-to-string
(concat "texdoc -l -M "
texdoc-query))))
(if (string-match "no documentation found" texdoc-output)
(error "Sorry, no documentation found for %s" texdoc-query)
(let ((texdoc-file (nth 2 (split-string texdoc-output))))
(if (file-readable-p texdoc-file)
(let ((new-file (make-temp-file
(format "TeX-find-texdoc--%s--" texdoc-query)
nil ".pdf")))
(copy-file texdoc-file new-file t)
(find-file-other-window new-file))
(error "Sorry, the file returned by texdoc for %s isn't readable"
texdoc-query)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment