12

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

Drew
  • 75,699
  • 9
  • 109
  • 225
syl20bnr
  • 2,095
  • 11
  • 21

2 Answers2

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.]

Drew
  • 75,699
  • 9
  • 109
  • 225
2

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.

Renan Ranelli
  • 1,379
  • 10
  • 17
  • Sorry Renan, Drew was the first to post the answer (less that 1 minute before you). Thank you for the answer :-) – syl20bnr Nov 05 '14 at 04:41