From fb1790bd6228617b18aa7b43913078f985cfbcc4 Mon Sep 17 00:00:00 2001 From: fpi Date: Fri, 10 Jul 2020 17:47:28 +0200 Subject: Add function to open bibtex pdf or directory Fallback to dired to let me execute `git annex get` on the missing pdf --- emacs-init.org | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'emacs-init.org') diff --git a/emacs-init.org b/emacs-init.org index 0e9a27d..5ce60a9 100644 --- a/emacs-init.org +++ b/emacs-init.org @@ -3333,12 +3333,26 @@ A small function to toggle the encryption state of the current entry. #+begin_src emacs-lisp (use-package org-ref :straight t + :bind (:map org-mode-map (("C-c n p" . fpi/open-bibtex-pdf-or-directory))) :custom (org-ref-bibliography-notes nil) (org-ref-notes-function 'org-ref-notes-function-many-files) (org-ref-notes-directory "~/git/projects/zettel/Lit") (org-ref-default-bibliography '("~/git/projects/personal/bib.bib")) - (org-ref-pdf-directory "~/git/projects/personal/Lit/")) + (org-ref-pdf-directory "~/git/projects/personal/Lit/") + :config + (defun fpi/open-bibtex-pdf-or-directory () + (interactive) + (save-excursion + (bibtex-beginning-of-entry) + (let* ((bibtex-expand-strings t) + (entry (bibtex-parse-entry t)) + (key (reftex-get-bib-field "=key=" entry)) + (pdf (funcall org-ref-get-pdf-filename-function key))) + (if (file-exists-p pdf) + (org-open-link-from-string (format "[[file:%s]]" pdf)) + (dired (file-name-directory pdf)) + (ding)))))) #+end_src ***** Capturing entries I store my bibtex references in an org file together with my notes. In -- cgit v1.2.3