mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(feat): Temporarily store link when capturing with ORP
* org-roam-protocol.el (org-roam-protocol-open-ref): Replicate default `org-protocol' behaviour temporarily for storing links * org-roam-capture.el (org-roam-capture--capture): Prevent stored link from being reset When capturing a web-page with org-roam-protocol, a link is now temporarily stored in `org-store-link-plist' via `org-link-store-props'. This is to allow the forwarding of properties to `org-capture', one of them being `:initial' which contains the content of the selected text in the browser.
This commit is contained in:
@ -512,7 +512,8 @@ GOTO and KEYS argument have the same functionality as
|
||||
`org-capture'."
|
||||
(let* ((org-capture-templates (mapcar #'org-roam-capture--convert-template org-roam-capture-templates))
|
||||
(one-template-p (= (length org-capture-templates) 1))
|
||||
org-capture-templates-contexts)
|
||||
org-capture-templates-contexts
|
||||
(org-capture-link-is-already-stored t))
|
||||
(when one-template-p
|
||||
(setq keys (caar org-capture-templates)))
|
||||
(if (or one-template-p
|
||||
|
@ -58,6 +58,33 @@ It opens or creates a note with the given ref.
|
||||
(error "No ref key provided"))
|
||||
(when-let ((title (cdr (assoc 'title decoded-alist))))
|
||||
(push (cons 'slug (funcall org-roam-title-to-slug-function title)) decoded-alist))
|
||||
(let* ((parts
|
||||
(pcase (org-protocol-parse-parameters info)
|
||||
;; New style links are parsed as a plist.
|
||||
((let `(,(pred keywordp) . ,_) info) info)
|
||||
;; Old style links, with or without template key, are
|
||||
;; parsed as a list of strings.
|
||||
(p
|
||||
(let ((k (if (= 1 (length (car p)))
|
||||
'(:template :url :title :body)
|
||||
'(:url :title :body))))
|
||||
(org-protocol-assign-parameters p k)))))
|
||||
(ref (and (plist-get parts :ref)
|
||||
(org-protocol-sanitize-uri (plist-get parts :ref))))
|
||||
(type (and ref
|
||||
(string-match "^\\([a-z]+\\):" ref)
|
||||
(match-string 1 ref)))
|
||||
(title (or (plist-get parts :title) ""))
|
||||
(region (or (plist-get parts :body) ""))
|
||||
(orglink
|
||||
(if (null ref) title
|
||||
(org-link-make-string ref (or (org-string-nw-p title) ref)))))
|
||||
(org-link-store-props :type type
|
||||
:link ref
|
||||
:description title
|
||||
:annotation orglink
|
||||
:initial region
|
||||
:query parts))
|
||||
(let* ((org-roam-capture-templates org-roam-capture-ref-templates)
|
||||
(org-roam-capture--context 'ref)
|
||||
(org-roam-capture--info decoded-alist)
|
||||
|
Reference in New Issue
Block a user