12

Is there a function for logging to Messages buffer without displaying in the echo-area? Or maybe another build in log mechanism?

I'm after a kind of console.log("string") kind of functionality.

Peter
  • 235
  • 1
  • 6
  • Here is a link that demonstrates how I do it: http://emacs.stackexchange.com/a/6003/2287 Essentially, the function `(messages-buffer)` is used to obtain the buffer or create one with the proper mode if it doesn't exist. The function -- using `(inhibit-read-only t)` -- goes to the bottom of the buffer and tests to see if it is at a new line, if not then create a new line, then insert the contents of the message (what ever it is), then test again to see if it is a new line, if not at new line then insert one. This method keeps the echo area available for stuff like interactive prompts. – lawlist Jun 01 '15 at 14:12

2 Answers2

10

With emacs-snapshot, you can let-bind inhibit-message to t:

Non-nil means calls to `message' are not displayed. They are still logged to the Messages buffer.

abo-abo
  • 13,943
  • 1
  • 29
  • 43
0

One way to do it is to call (message "") immediately after. This will, however, wipe out any existing content in the echo area.

(message "foo")
(message "")
legoscia
  • 6,012
  • 29
  • 54