bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

with-temp-message fails to restore an empty message


From: Alimony Petrofsky
Subject: with-temp-message fails to restore an empty message
Date: Sun, 16 Dec 2001 00:59:44 -0800

In GNU Emacs 21.1:

If the current message is nil when a with-temp-message form is
executed, then the temp message remains displayed after the body
exits.  Consequently, a "Frobnicating, please stand by..."  message
can result in an obedient user still bystanding long after the
frobnication is complete.  Pity the obedient.

Here's a fix:

 (defmacro with-temp-message (message &rest body)
   "Display MESSAGE temporarily if non-nil while BODY is evaluated.
 The original message is restored to the echo area after BODY has finished.
 The value returned is the value of the last form in BODY.
 MESSAGE is written to the message log buffer if `message-log-max' is non-nil.
 If MESSAGE is nil, the echo area and message log buffer are unchanged.
 Use a MESSAGE of \"\" to temporarily clear the echo area."
   (let ((current-message (make-symbol "current-message"))
        (temp-message (make-symbol "with-temp-message")))
     `(let ((,temp-message ,message)
           (,current-message))
        (unwind-protect
           (progn
             (when ,temp-message
               (setq ,current-message (current-message))
               (message "%s" ,temp-message))
             ,@body)
-        (and ,temp-message ,current-message
-             (message "%s" ,current-message))))))
+        (and ,temp-message
+             (message (and ,current-message "%s") ,current-message))))))


-al



reply via email to

[Prev in Thread] Current Thread [Next in Thread]