According to the Emacs manual, M-:
evaluates an Emacs Lisp expression and prints the value in the echo area. How can I direct the value to the current buffer instead?
use C-u M-:
insert the result into current buffer instead of printing it in the echo area.
(eval-expression EXP &optional INSERT-VALUE)
Evaluate EXP and print value in the echo area. When called interactively, read an Emacs Lisp expression and evaluate it. Value is also consed on to front of the variable ‘values’. If the resulting value is an integer, it will be printed in several additional formats (octal, hexadecimal, and character). Optional argument INSERT-VALUE non-nil (interactively, with prefix argument) means insert the result into the current buffer instead of printing it in the echo area.
-
Thanks for replying. I tried to follow your advice and evaluated
C-u M-x magit-version RET
while in the*sctach*
buffer, but the output wrote to the echo area rather than*scratch*
. – Evan Aad Apr 4 '17 at 9:04 -
-
-
1The
magit-version
command returns as a result only the version number, so that is what you can insert in to the buffer. If you look at the source formagit-version
you'll find that the additional information is displayed via the(message ....)
function -- so if you want that text you would need to temporarily advise / overridemessage
. – glucas Apr 4 '17 at 14:45 -
1What @glucas said. Or just pick up some of the code that prints that info in
*Messages*
(or similar) and use it to print the info wherever else you want. – Drew Apr 4 '17 at 14:47
*Messages*
buffer. You can switch to that buffer using(view-echo-area-messages)
which is bound toC-h e
by default. From that buffer you can freely copy text. – glucas Apr 4 '17 at 14:47M-:
output in to the current buffer? Why does that not work for one specific case,magit-version
? And totally unrelated, how does one get back to text that was shown in the echo area? – glucas Apr 4 '17 at 15:00M-:
in to the current buffer", which has already been answered. If the question you really intended to ask was "How can I copy the message echoed bymagit-version
" then please change the question, because that answer would have nothing to do withM-:
at all. – glucas Apr 4 '17 at 15:27