As I wrote in Emacs functions to open PDF in a dedicated frame, I find
it is better to make it consistent experience from the main entry
point M-x ivy-bibtex
.
Pushing ivy-set-actions
is not recommended by the author. The
suggested way is to copy to your .emacs
file and hard overwrite it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| (defun wr/ivy-open-pdf-in-top-frame (keys &optional fallback-action)
"Open the PDFs from interactive function `ivy-bibtex'."
(dolist (key keys)
(let* ((pdf (bibtex-completion-find-pdf key bibtex-completion-find-additional-pdfs))
(entry (bibtex-completion-get-entry key))
(title (bibtex-completion-apa-get-value "title" entry))
(s-title (truncate-string-to-width title 7))
(pdf-file (bibtex-completion-find-pdf key t)))
(cond
((> (length pdf) 1)
(let* ((pdf (f-uniquify-alist pdf))
(choice (completing-read "File to open: " (mapcar 'cdr pdf) nil t))
(file (car (rassoc choice pdf))))
(funcall bibtex-completion-pdf-open-function file)))
(pdf
(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))
(fallback-action
(funcall fallback-action (list key)))
(t
(message "No PDF(s) found for this entry: %s"
key))))))
(ivy-bibtex-ivify-action wr/ivy-open-pdf-in-top-frame wr/ivy-bibtex-open-pdf)
(ivy-set-actions
'ivy-bibtex
'(("p" ivy-bibtex-open-pdf "Open PDF file (if present)" ivy-bibtex-open-pdf)
("u" ivy-bibtex-open-url-or-doi "Open URL or DOI in browser" ivy-bibtex-open-url-or-doi)
("c" ivy-bibtex-insert-citation "Insert citation" ivy-bibtex-insert-citation)
("r" ivy-bibtex-insert-reference "Insert reference" ivy-bibtex-insert-reference)
("k" ivy-bibtex-insert-key "Insert BibTeX key" ivy-bibtex-insert-key)
("b" ivy-bibtex-insert-bibtex "Insert BibTeX entry" ivy-bibtex-insert-bibtex)
("a" ivy-bibtex-add-PDF-attachment "Attach PDF to email" ivy-bibtex-add-PDF-attachment)
("e" ivy-bibtex-edit-notes "Edit notes" ivy-bibtex-edit-notes)
("P" wr/ivy-bibtex-open-pdf "Open PDF file in TOP" wr/ivy-bibtex-open-pdf)
("s" ivy-bibtex-show-entry "Show entry" ivy-bibtex-show-entry)
("l" ivy-bibtex-add-pdf-to-library "Add PDF to library" ivy-bibtex-add-pdf-to-library)
("f" (lambda (_candidate) (ivy-bibtex-fallback ivy-text)) "Fallback options")))
|