diff options
author | Richard M. Stallman <rms@gnu.org> | 2003-09-30 12:47:04 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2003-09-30 12:47:04 +0000 |
commit | 9e1b128cd06ba6bd3d9c9dbefa88f35d2003d056 (patch) | |
tree | 699e6b58af0c14c79481c94e91001f6dc64b646c /lisp/emacs-lisp/lisp-mnt.el | |
parent | e927088b531a2e7c4fcb77d1feed1b30083d52d0 (diff) | |
download | emacs-9e1b128cd06ba6bd3d9c9dbefa88f35d2003d056.tar.gz |
(lm-with-file): When FILE is nil, run BODY in current buffer.
Diffstat (limited to 'lisp/emacs-lisp/lisp-mnt.el')
-rw-r--r-- | lisp/emacs-lisp/lisp-mnt.el | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index 893d95db05c..aeb7fb2258d 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -297,12 +297,14 @@ The returned value is a list of strings, one per line." (defmacro lm-with-file (file &rest body) "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 ,file)) - (when ,filesym - (with-temp-buffer - (insert-file-contents ,filesym) + (if ,filesym + (with-temp-buffer + (insert-file-contents ,filesym) + ,@body) + (save-excursion ,@body))))) (put 'lm-with-file 'lisp-indent-function 1) (put 'lm-with-file 'edebug-form-spec t) |