From 95e95b4b7079ffa281225344d84b4634ec868faf Mon Sep 17 00:00:00 2001 From: Bernd Grobauer Date: Sun, 14 Sep 2025 13:19:48 +0200 Subject: [PATCH 1/2] feat: Add functionality to provide id of parent node for new node and to provide path via a function. --- org-node.el | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/org-node.el b/org-node.el index 057079d..b4463b1 100644 --- a/org-node.el +++ b/org-node.el @@ -1051,7 +1051,11 @@ function is meant as a subroutine for creating a new file-level node. To merely visit an existing node, see `org-node-goto-id'. If the file already exists, this also attempts a `revert-buffer'." - (let* ((dir (or (plist-get plist :path) + (let* ( + (dir (or (and (plist-get plist :path) + (functionp (plist-get plist :path)) + (funcall (plist-get plist :path))) + (plist-get plist :path) (org-node-guess-or-ask-dir "New file in which directory? " (plist-get plist :ask-path)))) (file (file-name-concat dir (org-node-title-to-basename title))) @@ -1135,8 +1139,17 @@ type the name of a node that does not exist. That enables this ;; template string. (apply #'org-capture-put (org-node-capture-infer-title-etc)) (if-let* ((node (org-capture-get :existing-node))) - (org-node-goto node t) - (org-node-new-file-parameterized org-capture-plist)) + (org-node-goto node t) + (let ((parent-id (plist-get org-capture-plist :parent-id-if-new))) + (if parent-id + (if-let ((parent-node (org-mem-entry-by-id parent-id))) + (org-node-goto parent-node) + (user-error "No node found with ID: %s" parent-id)) + (org-node-new-file-parameterized org-capture-plist)))) + + ;;(if-let* ((node (org-capture-get :existing-node))) + ;; (org-node-goto node t) + ;; (org-node-new-file-parameterized org-capture-plist)) (when (eq (org-capture-get :type) 'plain) ;; Emulate part of `org-capture-place-plain-text'. We cannot just put the ;; capture property :target-entry-p t, because this may be a file-level From 13b5ca5712edca5f589c66c930dce58b7b926dae Mon Sep 17 00:00:00 2001 From: Bernd Grobauer Date: Sun, 14 Sep 2025 13:22:46 +0200 Subject: [PATCH 2/2] chore: remove commented out code. --- org-node.el | 4 ---- 1 file changed, 4 deletions(-) diff --git a/org-node.el b/org-node.el index b4463b1..389bca2 100644 --- a/org-node.el +++ b/org-node.el @@ -1146,10 +1146,6 @@ type the name of a node that does not exist. That enables this (org-node-goto parent-node) (user-error "No node found with ID: %s" parent-id)) (org-node-new-file-parameterized org-capture-plist)))) - - ;;(if-let* ((node (org-capture-get :existing-node))) - ;; (org-node-goto node t) - ;; (org-node-new-file-parameterized org-capture-plist)) (when (eq (org-capture-get :type) 'plain) ;; Emulate part of `org-capture-place-plain-text'. We cannot just put the ;; capture property :target-entry-p t, because this may be a file-level