Function: lm-with-file
lm-with-file is a macro defined in lisp-mnt.el.gz.
Signature
(lm-with-file FILE &rest BODY)
Documentation
Execute BODY in a buffer containing the contents of FILE.
If FILE is nil, execute BODY in the current buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp-mnt.el.gz
;; These give us smart access to the header fields and commentary
(defmacro lm-with-file (file &rest body)
"Execute BODY in a buffer containing the contents of FILE.
If FILE is nil, execute BODY in the current buffer."
(declare (indent 1) (debug t))
(let ((filesym (make-symbol "file")))
`(let ((,filesym ,file))
(if ,filesym
(with-temp-buffer
(insert-file-contents ,filesym)
(emacs-lisp-mode)
,@body)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
;; Switching major modes is too drastic, so just switch
;; temporarily to the Emacs Lisp mode syntax table.
(with-syntax-table emacs-lisp-mode-syntax-table
,@body)))))))