From ac76a48ee0ee471ad4d1f4a37101126d9e76ee73 Mon Sep 17 00:00:00 2001 From: Chris Barrett Date: Thu, 2 Mar 2023 21:01:49 +1300 Subject: [PATCH] Inhibit save hooks while saving WIP extracted buffer --- lisp/org-roam-rewrite.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/org-roam-rewrite.el b/lisp/org-roam-rewrite.el index 9f280eb..9fc41c7 100644 --- a/lisp/org-roam-rewrite.el +++ b/lisp/org-roam-rewrite.el @@ -408,8 +408,16 @@ but it handles file titles, tags and transclusions better." (with-current-buffer dest-buf (org-paste-subtree) (while (> (org-current-level) 1) (org-promote-subtree)) - (save-buffer) + + ;; `org-roam-promote-entire-buffer' expects an indexed node to + ;; exist, and the file must exist on-disk for indexing to succeed. + (let ((before-save-hook) + (after-save-hook + (lambda () + (org-id-add-location (org-roam-node-id node) dest)))) + (save-buffer)) (org-roam-promote-entire-buffer) + (let ((tags (-difference (-union (org-roam-rewrite--file-tags) tags) org-roam-rewrite-extract-excluded-tags))) (org-roam-rewrite--set-file-tags tags)