Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bugfix): propagate org-roam-directory to temp buffers #275

Merged
merged 4 commits into from
Mar 11, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the closing quote is a single quote, you should see a difference in the syntax highlight.

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