Q: how do I print a message in the echo area without surrounding quotes?
Here's a simple command:
(defun test-fn ()
(interactive)
(message "Test message"))
When I call it as an interactive command via M-x test-fn
, it prints Test message
in the echo areas without surrounding quotation marks. However, when I evaluate it in elisp as (test-fn)
, it prints "Test message"
in the echo area with surrounding quotation marks.
First of all, why is there a difference between these two use cases? Second, and more to the point, how can I call the function non-interactively and have the message print to the echo area without the surrounding quotes?
message
function returns its argument. If you wanttest-fn
to return something else then return it. Put differently the effect you see in the*Messages*
buffer and in the REPL are due to different things: (1) is due tomessage
sending a string to an output stream, (2) is due tomessage
returning the formatted string.