Skip to content

Commit

Permalink
New function orb-open-associated-note
Browse files Browse the repository at this point in the history
  • Loading branch information
premopie authored and myshevchuk committed Jan 13, 2022
1 parent c6fbc98 commit 53a4e8b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions org-roam-bibtex.el
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,31 @@ bibliographic information."
;; (v (list :path file-path :title title)))
;; (push (cons k v) completions)))))))

;;;###autoload
(defun orb-open-associated-note (&optional element)
"Open an Org-roam note associated with the Org citation element
around point or with the optional ELEMENT argument.
When non-nil the ELEMENT argument should be the Org citation or
Org citation reference element. Providing it allows for quicker
computation.
"
(let*
((around-point (not element))
(element (if around-point (org-element-context) element))
(type (org-element-type element))
(citekey
(cond
((eq type 'citation)
(org-element-property :key (car (org-cite-get-references element))))
((eq type 'citation-reference)
(org-element-property :key element))
(around-point
(user-error "Cursor outside a citation element!"))
(t
(user-error "Invalid optional argument ELEMENT!")))))
(orb-edit-note citekey)))

;; ============================================================================
;;;; Orb insert
;; ============================================================================
Expand Down

0 comments on commit 53a4e8b

Please sign in to comment.