diff options
author | fpi | 2020-07-10 17:47:28 +0200 |
---|---|---|
committer | fpi | 2020-07-10 17:48:53 +0200 |
commit | fb1790bd6228617b18aa7b43913078f985cfbcc4 (patch) | |
tree | 59d1f63e7959ce324c97c714076947bda1098948 | |
parent | Increase refile targets level some more (diff) |
Add function to open bibtex pdf or directory
Fallback to dired to let me execute `git annex get` on the missing pdf
Diffstat (limited to '')
-rw-r--r-- | emacs-init.org | 16 |
1 files changed, 15 insertions, 1 deletions
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 |