Skip to content

Commit

Permalink
(bugfix): propagate org-roam-directory to temp buffers (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
herbertjones committed Mar 11, 2020
1 parent 6eb7238 commit f856bef
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions org-roam.el
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,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)
Expand Down Expand Up @@ -425,6 +425,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."
Expand Down Expand Up @@ -1101,7 +1111,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]
Expand Down

0 comments on commit f856bef

Please sign in to comment.