mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
add ref
This commit is contained in:
@ -149,11 +149,14 @@ This function is to be called in the Org-capture finalization process."
|
|||||||
"Add REF to the newly captured item."
|
"Add REF to the newly captured item."
|
||||||
(let ((buf (org-capture-get :buffer))
|
(let ((buf (org-capture-get :buffer))
|
||||||
(pos (org-capture-get :exact-position))
|
(pos (org-capture-get :exact-position))
|
||||||
orig-ref)
|
ref-lst)
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(org-with-point-at pos
|
(org-with-point-at pos
|
||||||
(setq orig-ref (split-string-and-unquote (org-entry-get (point) "ROAM_REFS")))
|
(setq ref-lst (org-entry-get (point) "ROAM_REFS"))
|
||||||
(org-set-property "ROAM_REFS" (combine-and-quote-strings (cl-pushnew orig-ref ref)))))))
|
(setq ref-lst (if ref-lst
|
||||||
|
(cl-pushnew ref-lst ref)
|
||||||
|
(list ref)))
|
||||||
|
(org-set-property "ROAM_REFS" (combine-and-quote-strings ref-lst))))))
|
||||||
|
|
||||||
(defun org-roam-capture--finalize ()
|
(defun org-roam-capture--finalize ()
|
||||||
"Finalize the `org-roam-capture' process."
|
"Finalize the `org-roam-capture' process."
|
||||||
@ -305,22 +308,19 @@ you can catch it with `condition-case'."
|
|||||||
"Return exact point to file for org-capture-template.
|
"Return exact point to file for org-capture-template.
|
||||||
This function is used solely in Org-roam's capture templates: see
|
This function is used solely in Org-roam's capture templates: see
|
||||||
`org-roam-capture-templates'."
|
`org-roam-capture-templates'."
|
||||||
(let* ((file-path
|
(when-let ((time (cdr (assoc 'time org-roam-capture--info))))
|
||||||
|
(org-capture-put :default-time time))
|
||||||
|
(let ((file-path
|
||||||
(cond ((assoc 'file org-roam-capture--info)
|
(cond ((assoc 'file org-roam-capture--info)
|
||||||
(cdr (assoc 'file org-roam-capture--info)))
|
(cdr (assoc 'file org-roam-capture--info)))
|
||||||
((assoc 'ref org-roam-capture--info)
|
((assoc 'ref org-roam-capture--info)
|
||||||
(let ((ref (cdr (assoc 'ref org-roam-capture--info))))
|
(let ((ref (cdr (assoc 'ref org-roam-capture--info))))
|
||||||
(if-let ((file ((caar (org-roam-db-query
|
(or (caar (org-roam-db-query [:select [file]
|
||||||
[:select [file]
|
|
||||||
:from refs
|
:from refs
|
||||||
:where (= ref $s1)
|
:where (= ref $s1)
|
||||||
:limit 1]
|
:limit 1] ref))
|
||||||
ref)))))
|
(org-roam-capture--new-file))))
|
||||||
file
|
|
||||||
(user-error "No such ref \"%s\"" ref))))
|
|
||||||
(t
|
(t
|
||||||
(when-let ((time (cdr (assoc 'time org-roam-capture--info))))
|
|
||||||
(org-capture-put :default-time time))
|
|
||||||
(org-roam-capture--new-file)))))
|
(org-roam-capture--new-file)))))
|
||||||
(org-capture-put :template
|
(org-capture-put :template
|
||||||
(org-roam-capture--fill-template (org-capture-get :template)))
|
(org-roam-capture--fill-template (org-capture-get :template)))
|
||||||
@ -330,7 +330,7 @@ This function is used solely in Org-roam's capture templates: see
|
|||||||
(set-buffer (org-capture-target-buffer file-path))
|
(set-buffer (org-capture-target-buffer file-path))
|
||||||
(widen)
|
(widen)
|
||||||
(if-let* ((olp (org-roam-capture--get :olp)))
|
(if-let* ((olp (org-roam-capture--get :olp)))
|
||||||
(condition-case errg
|
(condition-case err
|
||||||
(when-let ((marker (org-roam-capture-find-or-create-olp olp)))
|
(when-let ((marker (org-roam-capture-find-or-create-olp olp)))
|
||||||
(goto-char marker)
|
(goto-char marker)
|
||||||
(set-marker marker nil))
|
(set-marker marker nil))
|
||||||
|
@ -77,14 +77,14 @@ It opens or creates a note with the given ref.
|
|||||||
(org-link-store-props :type type
|
(org-link-store-props :type type
|
||||||
:link ref
|
:link ref
|
||||||
:annotation orglink
|
:annotation orglink
|
||||||
:initial body))
|
:initial body)
|
||||||
(raise-frame)
|
(raise-frame)
|
||||||
(org-roam-capture--capture
|
(org-roam-capture--capture
|
||||||
:keys (cdr (assoc 'template decoded-alist))
|
:keys (cdr (assoc 'template decoded-alist))
|
||||||
:info decoded-alist
|
:info decoded-alist
|
||||||
:props (list :ref ref)
|
:props (list :ref ref)
|
||||||
:templates org-roam-capture-ref-templates)))
|
:templates org-roam-capture-ref-templates)))
|
||||||
nil)
|
nil))
|
||||||
|
|
||||||
(defun org-roam-protocol-open-file (info)
|
(defun org-roam-protocol-open-file (info)
|
||||||
"This handler simply opens the file with emacsclient.
|
"This handler simply opens the file with emacsclient.
|
||||||
|
Reference in New Issue
Block a user