297 |
|
|
298 |
(defmacro lm-with-file (file &rest body) |
(defmacro lm-with-file (file &rest body) |
299 |
"Execute BODY in a buffer containing the contents of FILE. |
"Execute BODY in a buffer containing the contents of FILE. |
300 |
If FILE is nil, just return nil." |
If FILE is nil, execute BODY in the current buffer." |
301 |
(let ((filesym (make-symbol "file"))) |
(let ((filesym (make-symbol "file"))) |
302 |
`(let ((,filesym ,file)) |
`(let ((,filesym ,file)) |
303 |
(when ,filesym |
(if ,filesym |
304 |
(with-temp-buffer |
(with-temp-buffer |
305 |
(insert-file-contents ,filesym) |
(insert-file-contents ,filesym) |
306 |
|
,@body) |
307 |
|
(save-excursion |
308 |
,@body))))) |
,@body))))) |
309 |
(put 'lm-with-file 'lisp-indent-function 1) |
(put 'lm-with-file 'lisp-indent-function 1) |
310 |
(put 'lm-with-file 'edebug-form-spec t) |
(put 'lm-with-file 'edebug-form-spec t) |