mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-13 17:40:22 -08:00
(lm-with-file): When FILE is nil, run BODY in current buffer.
This commit is contained in:
parent
e927088b53
commit
9e1b128cd0
1 changed files with 6 additions and 4 deletions
|
|
@ -297,12 +297,14 @@ The returned value is a list of strings, one per line."
|
||||||
|
|
||||||
(defmacro lm-with-file (file &rest body)
|
(defmacro lm-with-file (file &rest body)
|
||||||
"Execute BODY in a buffer containing the contents of FILE.
|
"Execute BODY in a buffer containing the contents of FILE.
|
||||||
If FILE is nil, just return nil."
|
If FILE is nil, execute BODY in the current buffer."
|
||||||
(let ((filesym (make-symbol "file")))
|
(let ((filesym (make-symbol "file")))
|
||||||
`(let ((,filesym ,file))
|
`(let ((,filesym ,file))
|
||||||
(when ,filesym
|
(if ,filesym
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents ,filesym)
|
(insert-file-contents ,filesym)
|
||||||
|
,@body)
|
||||||
|
(save-excursion
|
||||||
,@body)))))
|
,@body)))))
|
||||||
(put 'lm-with-file 'lisp-indent-function 1)
|
(put 'lm-with-file 'lisp-indent-function 1)
|
||||||
(put 'lm-with-file 'edebug-form-spec t)
|
(put 'lm-with-file 'edebug-form-spec t)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue