Function: org-roam-with-temp-buffer

org-roam-with-temp-buffer is a macro defined in org-roam-utils.el.

Signature

(org-roam-with-temp-buffer FILE &rest BODY)

Documentation

Execute BODY within a temp buffer.

Like with-temp-buffer, but propagates org-roam-directory. If FILE, set default-directory to FILE's directory and insert its contents.

Source Code

;; Defined in ~/.emacs.d/elpa/org-roam-20260224.1637/org-roam-utils.el
;;; Buffer utilities
(defmacro org-roam-with-temp-buffer (file &rest body)
  "Execute BODY within a temp buffer.
Like `with-temp-buffer', but propagates `org-roam-directory'.
If FILE, set `default-directory' to FILE's directory and insert its contents."
  (declare (indent 1) (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)
               (org-inhibit-startup t))
           (delay-mode-hooks (org-mode))
           (when ,file
             (insert-file-contents ,file)
             (setq-local default-directory (file-name-directory ,file)))
           ,@body)))))