11

Is it possible to display a message in the echo area without logging it in buffer *Messages*?

12

Bind message-log-max to nil:

(defun foo ()
  (interactive)
  (let ((message-log-max nil))
    (message "EEEEEEEEEEEEEEEEEE")))

M-x foo RET

[P.S. Don't be misled by tests using things such as M-: (let ((message-log-max nil)) (message "EEEEEEEEEEEEEEEEEE")) into thinking that the EEEEEEEEEEEEEEEEEE from evaluating the let sexp is the message that was output by message. It is instead the value returned by that evaluation. message does not log anything to *Messages* if message-log-max is nil.]

1

I couldn't find a built in way to do it, so I hacked this weird function:

(defun echo-and-ignore-message-buffer (message)
  (let ((prev-msg-log-max message-log-max))
    (unwind-protect
        (progn (setq message-log-max nil)
               (message message))
      (setq message-log-max prev-msg-log-max))))

Check out the documentation for message-log-max.

  • Sorry Renan, Drew was the first to post the answer (less that 1 minute before you). Thank you for the answer :-) – syl20bnr Nov 5 '14 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.