Skip to content

Instantly share code, notes, and snippets.

@ryseto
Created March 29, 2012 20:39
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 ryseto/2243572 to your computer and use it in GitHub Desktop.
Save ryseto/2243572 to your computer and use it in GitHub Desktop.
Open PDF file by the cite key: \cite{foo} -> open foo.pdf
(defun MyTeX-open-article ()
"Open PDF file by the cite key: \cite{foo} -> open foo.pdf"
(interactive)
(let* ((s (save-excursion
(skip-chars-backward "^{,")
(point)))
(e (save-excursion
(skip-chars-forward "^},")
(point)))
(pdfdir "~/Documents/Dropbox/Papers/pdf/")
(pdffile (concat pdfdir
(buffer-substring-no-properties s e) ".pdf"))
(process-kill-without-query
(start-process-shell-command "Open the article" nil "open" pdffile)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment