aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1998-11-19 09:43:40 +0000
committerSimon Marshall1998-11-19 09:43:40 +0000
commite5bb8a8cd802d0a3f7e61c29411a7fb2392634f4 (patch)
tree261974d002032f80a5d9f3fc8366e18f0a67bf58
parent18aa807e60761a03ae4dab9d0056220078096cd0 (diff)
downloademacs-e5bb8a8cd802d0a3f7e61c29411a7fb2392634f4.tar.gz
emacs-e5bb8a8cd802d0a3f7e61c29411a7fb2392634f4.zip
Added with-temp-message.
-rw-r--r--lisp/subr.el27
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 9bea598b8a5..63ea674a1c1 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -937,9 +937,9 @@ See also `with-temp-buffer'."
937 (set-buffer ,buffer) 937 (set-buffer ,buffer)
938 ,@body)) 938 ,@body))
939 939
940(defmacro with-temp-file (file &rest forms) 940(defmacro with-temp-file (file &rest body)
941 "Create a new buffer, evaluate FORMS there, and write the buffer to FILE. 941 "Create a new buffer, evaluate BODY there, and write the buffer to FILE.
942The value of the last form in FORMS is returned, like `progn'. 942The value returned is the value of the last form in BODY.
943See also `with-temp-buffer'." 943See also `with-temp-buffer'."
944 (let ((temp-file (make-symbol "temp-file")) 944 (let ((temp-file (make-symbol "temp-file"))
945 (temp-buffer (make-symbol "temp-buffer"))) 945 (temp-buffer (make-symbol "temp-buffer")))
@@ -949,22 +949,35 @@ See also `with-temp-buffer'."
949 (unwind-protect 949 (unwind-protect
950 (prog1 950 (prog1
951 (with-current-buffer ,temp-buffer 951 (with-current-buffer ,temp-buffer
952 ,@forms) 952 ,@body)
953 (with-current-buffer ,temp-buffer 953 (with-current-buffer ,temp-buffer
954 (widen) 954 (widen)
955 (write-region (point-min) (point-max) ,temp-file nil 0))) 955 (write-region (point-min) (point-max) ,temp-file nil 0)))
956 (and (buffer-name ,temp-buffer) 956 (and (buffer-name ,temp-buffer)
957 (kill-buffer ,temp-buffer)))))) 957 (kill-buffer ,temp-buffer))))))
958 958
959(defmacro with-temp-buffer (&rest forms) 959(defmacro with-temp-message (message &rest body)
960 "Create a temporary buffer, and evaluate FORMS there like `progn'. 960 "Display MESSAGE temporarily while BODY is evaluated.
961The original message is restored to the echo area after BODY has finished.
962The value returned is the value of the last form in BODY.
963MESSAGE is written to the message log buffer if `message-log-max' is non-nil."
964 (let ((current-message (make-symbol "current-message")))
965 `(let ((,current-message (current-message)))
966 (unwind-protect
967 (progn
968 (message ,message)
969 ,@body)
970 (message ,current-message)))))
971
972(defmacro with-temp-buffer (&rest body)
973 "Create a temporary buffer, and evaluate BODY there like `progn'.
961See also `with-temp-file' and `with-output-to-string'." 974See also `with-temp-file' and `with-output-to-string'."
962 (let ((temp-buffer (make-symbol "temp-buffer"))) 975 (let ((temp-buffer (make-symbol "temp-buffer")))
963 `(let ((,temp-buffer 976 `(let ((,temp-buffer
964 (get-buffer-create (generate-new-buffer-name " *temp*")))) 977 (get-buffer-create (generate-new-buffer-name " *temp*"))))
965 (unwind-protect 978 (unwind-protect
966 (with-current-buffer ,temp-buffer 979 (with-current-buffer ,temp-buffer
967 ,@forms) 980 ,@body)
968 (and (buffer-name ,temp-buffer) 981 (and (buffer-name ,temp-buffer)
969 (kill-buffer ,temp-buffer)))))) 982 (kill-buffer ,temp-buffer))))))
970 983