diff options
author | Thanos Apollo <[email protected]> | 2024-12-18 23:25:50 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-12-18 23:31:39 +0200 |
commit | 9eedd4fa2e6fc8ec02588d630f39ac0c04451773 (patch) | |
tree | 796f220f128f582060de72b79bcd3b37761710b8 | |
parent | e8de093180d6f8f86262683f6e4ffc27f638dd22 (diff) |
org-gnosis-insert: Create node if it does not already exist.
* If user enters a node that does not exist, create it & insert it as an id link.
-rw-r--r-- | org-gnosis.el | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/org-gnosis.el b/org-gnosis.el index f7e10c2..b1dd302 100644 --- a/org-gnosis.el +++ b/org-gnosis.el @@ -359,13 +359,24 @@ instead." ;;;###autoload (defun org-gnosis-insert () - "Insert gnosis node." + "Insert gnosis node. + +If node does not exist, create it." (interactive) (let* ((node (org-gnosis--find "Select gnosis node: " (org-gnosis-select '[title tags] 'nodes '1=1) (org-gnosis-select 'title 'nodes '1=1))) (id (concat "id:" (car (org-gnosis-select 'id 'nodes `(= ,node title) '1=1))))) - (org-insert-link nil id node))) + (cond ((< (length id) 4) + (save-window-excursion + (org-gnosis--create-file node) + ;; Save buffer to store new node id + (save-buffer) + (setf id (concat "id:" + (car (org-gnosis-select 'id 'nodes `(= ,node title) '1=1))))) + (org-insert-link nil id node) + (message "Created new node: %s" node)) + (t (org-insert-link nil id node))))) ;;;###autoload (defun org-gnosis-insert-tag () |