noctuid / link-hint.el

Pentadactyl-like Link Hinting in Emacs with Avy
GNU General Public License v3.0
160 stars 22 forks source link

[citation] link cannot identify multiple links #209

Closed randomwangran closed 1 year ago

randomwangran commented 2 years ago

If the citation has a format like this:

link-hint-open-link can only identify the =citation= as one link.

image

However, if the cursor is on a different key, the open command will result in different things.

Condition 1: image

Will open feynman2011feynman.

Condition 2: image

Will open hutchings2018surely.

org-ref-next-key can identify the links in a finner level, so that would be a good starting point.

randomwangran commented 1 year ago

There is a function in org-ref-citation-link.el:

(defun org-ref-jump-to-visible-key ()
  "Jump to a visible key with avy."
  (interactive)
  (avy-with avy-goto-key
    (avy-process
     (apply #'append
            (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)))

So, the user can have finner control over the Dropping Zone (DZ).