Function: denote--file-with-temp-buffer
denote--file-with-temp-buffer is a macro defined in denote.el.
Signature
(denote--file-with-temp-buffer FILE &rest BODY)
Documentation
Evaluate BODY with FILE contents in scope.
If a buffer is visiting FILE, insert the buffer contents into a temporary buffer. Otherwise, insert the contents of FILE. Then call BODY.
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defmacro denote--file-with-temp-buffer (file &rest body)
"Evaluate BODY with FILE contents in scope.
If a buffer is visiting FILE, insert the buffer contents into a
temporary buffer. Otherwise, insert the contents of FILE. Then call
BODY."
(declare (indent 1))
`(let* ((buffer (get-file-buffer ,file))
(file-exist (file-exists-p ,file)))
(with-temp-buffer
(cond
(buffer (insert-buffer-substring buffer))
(file-exist (insert-file-contents ,file))
(t (error "Cannot find anything about file `%s'" ,file)))
(goto-char (point-min))
,@body)))