diff lisp/emacs-lisp/lisp-mnt.el @ 52687:fb1ccaa34830

(lm-with-file): When FILE is nil, run BODY in current buffer.
author Richard M. Stallman <rms@gnu.org>
date Tue, 30 Sep 2003 12:47:04 +0000
parents e4693bed89ad
children daa5c6e18f62
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mnt.el	Tue Sep 30 12:45:44 2003 +0000
+++ b/lisp/emacs-lisp/lisp-mnt.el	Tue Sep 30 12:47:04 2003 +0000
@@ -297,12 +297,14 @@
 
 (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)