Last active
August 29, 2015 14:07
-
-
Save vermiculus/b48f68d46827b9a4b8ac to your computer and use it in GitHub Desktop.
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 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