This commit is contained in:
Jethro Kuan
2021-04-10 00:32:55 +08:00
parent 1b1d2b2b76
commit 09b0d74359
2 changed files with 29 additions and 29 deletions

View File

@ -149,11 +149,14 @@ This function is to be called in the Org-capture finalization process."
"Add REF to the newly captured item."
(let ((buf (org-capture-get :buffer))
(pos (org-capture-get :exact-position))
orig-ref)
ref-lst)
(with-current-buffer buf
(org-with-point-at pos
(setq orig-ref (split-string-and-unquote (org-entry-get (point) "ROAM_REFS")))
(org-set-property "ROAM_REFS" (combine-and-quote-strings (cl-pushnew orig-ref ref)))))))
(setq ref-lst (org-entry-get (point) "ROAM_REFS"))
(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 ()
"Finalize the `org-roam-capture' process."
@ -305,23 +308,20 @@ you can catch it with `condition-case'."
"Return exact point to file for org-capture-template.
This function is used solely in Org-roam's capture templates: see
`org-roam-capture-templates'."
(let* ((file-path
(cond ((assoc 'file org-roam-capture--info)
(cdr (assoc 'file org-roam-capture--info)))
((assoc 'ref org-roam-capture--info)
(let ((ref (cdr (assoc 'ref org-roam-capture--info))))
(if-let ((file ((caar (org-roam-db-query
[:select [file]
:from refs
:where (= ref $s1)
:limit 1]
ref)))))
file
(user-error "No such ref \"%s\"" ref))))
(t
(when-let ((time (cdr (assoc 'time org-roam-capture--info))))
(org-capture-put :default-time time))
(org-roam-capture--new-file)))))
(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)
(cdr (assoc 'file org-roam-capture--info)))
((assoc 'ref org-roam-capture--info)
(let ((ref (cdr (assoc 'ref org-roam-capture--info))))
(or (caar (org-roam-db-query [:select [file]
:from refs
:where (= ref $s1)
:limit 1] ref))
(org-roam-capture--new-file))))
(t
(org-roam-capture--new-file)))))
(org-capture-put :template
(org-roam-capture--fill-template (org-capture-get :template)))
(org-roam-capture--put :file-path file-path
@ -330,7 +330,7 @@ This function is used solely in Org-roam's capture templates: see
(set-buffer (org-capture-target-buffer file-path))
(widen)
(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)))
(goto-char marker)
(set-marker marker nil))

View File

@ -77,14 +77,14 @@ It opens or creates a note with the given ref.
(org-link-store-props :type type
:link ref
:annotation orglink
:initial body))
(raise-frame)
(org-roam-capture--capture
:keys (cdr (assoc 'template decoded-alist))
:info decoded-alist
:props (list :ref ref)
:templates org-roam-capture-ref-templates)))
nil)
:initial body)
(raise-frame)
(org-roam-capture--capture
:keys (cdr (assoc 'template decoded-alist))
:info decoded-alist
:props (list :ref ref)
:templates org-roam-capture-ref-templates)))
nil))
(defun org-roam-protocol-open-file (info)
"This handler simply opens the file with emacsclient.