From 0cab668d9e68651af3c569cc24e31ce1a3d9be06 Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Wed, 11 Mar 2020 15:41:18 +0800 Subject: [PATCH] (bugfix): propagate org-roam-directory to temp buffers (#275) --- org-roam.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/org-roam.el b/org-roam.el index 0942889..5576e18 100644 --- a/org-roam.el +++ b/org-roam.el @@ -351,7 +351,7 @@ This is equivalent to removing the node from the graph." (time (current-time)) all-files all-links all-titles all-refs) (dolist (file org-roam-files) - (with-temp-buffer + (org-roam--with-temp-buffer (insert-file-contents file) (let ((contents-hash (secure-hash 'sha1 (current-buffer)))) (unless (string= (gethash file current-files) @@ -436,6 +436,16 @@ https://github.com/kaushalmodi/ox-hugo/blob/a80b250987bc770600c424a10b3bca6ff728 (setq ret (append ret str-list2)))) ret))) +(defmacro org-roam--with-temp-buffer (&rest body) + "Call `with-temp-buffer', propagating `org-roam-directory' to +the temp buffer." + (declare (indent 0) (debug t)) + (let ((current-org-roam-directory (make-symbol "current-org-roam-directory"))) + `(let ((,current-org-roam-directory org-roam-directory)) + (with-temp-buffer + (let ((org-roam-directory ,current-org-roam-directory)) + ,@body))))) + ;;;; File functions and predicates (defun org-roam--touch-file (path) "Touches an empty file at PATH." @@ -1130,7 +1140,7 @@ The Org-roam database titles table is read, to obtain the list of titles. The file-links table is then read to obtain all directed links, and formatted into a digraph." (org-roam--db-ensure-built) - (with-temp-buffer + (org-roam--with-temp-buffer (let* ((matcher (concat "%" org-roam-graph-exclude-matcher "%")) (nodes (if org-roam-graph-exclude-matcher (org-roam-sql [:select [file titles]