org-ref-jump-to-visible-key
can identify multiple candidates, but it
does not contain a regular link in Org-mode. link-hint-open-link
on the
other hand, can identify a normal link but is not very good at finding
multiple citation keys. We need a strong merge.
Following code snippet can merge two types of link, but I don’t feel
this is the best way to achieve this.
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
| (defun wr/pos-getter (arg)
(plist-get arg :pos))
(defun wr/org-ref-jump-to-visible-key ()
"Jump to a visible key with avy."
(interactive)
(avy-with avy-goto-key
(avy-process
(apply #'append
(list
(append (mapcar #'wr/pos-getter (link-hint--get-links))
(car (save-excursion
(org-element-map (org-element-parse-buffer) 'link
(lambda (c)
(when (assoc (org-element-property :type c) org-ref-cite-types)
(goto-char (org-element-property :begin c))
(let* ((path (org-element-property :path c))
(data (org-ref-parse-cite-path path))
(references (plist-get data :references)))
(append (list (org-element-property :begin c))
(cl-loop for ref in references collect
(progn
(search-forward (plist-get ref :key))
(match-beginning 0))))))))))))))
(avy--style-fn avy-style))
(org-open-at-point))
|
Reminder: make sure the citation has the correct format, which is
double square brackets. Otherwise, you cannot jump to the desired
location.