Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defmacro with-transient-file (file-name &rest code)
"Load FILE-NAME into a buffer and eval CODE.
Then dispose of the buffer.
File loading errors may be generated as by any call to visit a
(declare (indent 1)
(debug (sexp &rest form)))
(let ((fvn (make-symbol "fv"))
(bvn (make-symbol "bv")))
`(let* ((,fvn ,file-name)
(,bvn (get-buffer-create
(generate-new-buffer-name "transient"))))
(with-current-buffer ,bvn
(insert-file-contents-literally ,fvn)
(set-buffer-modified-p nil)
(kill-buffer ,bvn))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment