Create a test.el
file as below:
(print "hello world!")
Then run M-x eval-buffer
. No output can be seen even in *Messages*
buffer. where is the print output for this case?
Nowhere. See the docstring (C-h f eval-buffer
):
(eval-buffer &optional BUFFER PRINTFLAG FILENAME UNIBYTE DO-ALLOW-PRINT)
Execute the accessible portion of current buffer as Lisp code. ...
PRINTFLAG controls printing of output by any output functions in the evaluated code, such as ‘print’, ‘princ’, and ‘prin1’: a value of nil means discard it; anything else is the stream to print to. See Info node ‘(elisp)Output Streams’ for details on streams.
...
DO-ALLOW-PRINT, if non-nil, specifies that output functions in the evaluated code should work normally even if PRINTFLAG is nil, in which case the output is displayed in the echo area.
C-x C-e
(eval-last-sexp
) with point after the (print "hello")
you will see the text appears two times in the echo area. One is the result of evaluation, the other is the string printed by side effect. Try this with (+ 4 2)
for example. What are you trying to achieve?
Commented
Aug 11, 2017 at 8:50
(message "hello world!")
will print hello world!
to the echo area. That's the same space that's used by the minibuffer: echo area for output, minibuffer for input.