When I read pdf, I often open those files in a dedicated frame to study. So, I need to do this quickly.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(defun wr/org-ref-open-pdf-at-point ()
  "Open the pdf for bibtex key under point if it exists."
  (interactive)
  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
         (results (org-ref-get-bibtex-key-and-file))
         (key (car results))
         (pdf-file (bibtex-completion-find-pdf key t))
         (entry (bibtex-completion-get-entry key))
         (title (bibtex-completion-apa-get-value "title" entry))
         (s-title (truncate-string-to-width title 7)))
    (pcase (length pdf-file)
      (0
       (message "no pdf found for %s" key))
      (1
       (icicle-select-frame-by-name "TOP")
       (tab-bar-new-tab)
       (tab-bar-rename-tab s-title)
       (org-open-file (car pdf-file))
       (my-split-window-horizontally)
       (bibtex-completion-edit-notes (list key))
       (other-window 1))
      (_
       (org-open-file (completing-read "pdf: " pdf-file))))))

It is more consistent if the opening process is issued from the same process: org-open-at-point. So, we need to define a hydra:

1
2
(defhydra+ org-ref-citation-hydra (:color purple :hint nil)
    ("P" wr/org-ref-open-pdf-at-point "Open Pdf in TOP frame" :column "WR Pdf" :color purple))