5

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?

Drew
  • 75,699
  • 9
  • 109
  • 225
lucky1928
  • 1,622
  • 8
  • 28

2 Answers2

3

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.

JeanPierre
  • 7,323
  • 1
  • 18
  • 37
  • @JeanPiere Thanks, but if I do it as ` (eval-buffer nil (get-buffer-create "test"))`, it works but 1) all function name printed automatically. 2) the print output is duplicated. Maybe I missed some configure! – lucky1928 Aug 11 '17 at 01:58
  • 1
    @lucky1928 If you do `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? – JeanPierre Aug 11 '17 at 08:50
1
(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.

Drew
  • 75,699
  • 9
  • 109
  • 225
akindofyoga
  • 111
  • 4