(feat)capture: create ID before capture process (#2049)

* (feat)capture: create ID before capture process

This allows the ID to be used as part of the capture template. Addresses #2048.

* update changelog
This commit is contained in:
Jethro Kuan
2022-01-19 13:41:20 -08:00
committed by GitHub
parent 47ad646d51
commit bf3ebe2121
2 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,8 @@
# Changelog # Changelog
## TBD ## TBD
### Added ### Added
- [#2042](https://github.com/org-roam/org-roam/pull/2042) Add `org-roam-db-extra-links-elements` and `org-roam-db-extra-links-exclude-keys` for fine-grained control over additional link parsing. - [#2042](https://github.com/org-roam/org-roam/pull/2042) db: add `org-roam-db-extra-links-elements` and `org-roam-db-extra-links-exclude-keys` for fine-grained control over additional link parsing
- [#2049](https://github.com/org-roam/org-roam/pull/2049) capture: allow ID to be used as part of `org-roam-capture-templates`
### Removed ### Removed
### Fixed ### Fixed
### Changed ### Changed

View File

@ -407,6 +407,8 @@ TEMPLATES is a list of org-roam templates."
(mapcar (lambda (template) (mapcar (lambda (template)
(org-roam-capture--convert-template template props)) (org-roam-capture--convert-template template props))
(or templates org-roam-capture-templates))) (or templates org-roam-capture-templates)))
(_ (setf (org-roam-node-id node) (or (org-roam-node-id node)
(org-id-new))))
(org-roam-capture--node node) (org-roam-capture--node node)
(org-roam-capture--info info)) (org-roam-capture--info info))
(when (and (not keys) (when (and (not keys)
@ -572,12 +574,10 @@ Return the ID of the location."
;; caller. ;; caller.
(save-excursion (save-excursion
(goto-char p) (goto-char p)
(when-let* ((node org-roam-capture--node) (if-let ((id (org-entry-get p "ID")))
(id (org-roam-node-id node))) (setf (org-roam-node-id org-roam-capture--node) id)
(org-entry-put p "ID" id)) (org-entry-put p "ID" (org-roam-node-id org-roam-capture--node)))
(prog1 (run-hooks 'org-roam-capture-new-node-hook))))
(org-id-get-create)
(run-hooks 'org-roam-capture-new-node-hook)))))
(defun org-roam-capture--get-target () (defun org-roam-capture--get-target ()
"Get the current capture :target for the capture template in use." "Get the current capture :target for the capture template in use."