6

In Emacs 24.4, every time I evaluate a form in ielm or using C-x C-e it prints a lot of extraneous output that while useful, sometimes gets in the way. As an example,

(+ 1 1)
;=> 2 (#o2, #x2, ?\C-b)

Is there a variable I can use to disable printing this extra information and have it just display 2 like it used to?

  • When you say "evaluate", do you mean C-x C-e? – Malabarba Nov 20 '14 at 0:16
  • I mean C-x C-e and ielm. I'm not aware of a single way of evaluating elisp that doesn't return this extra information by default. – wdkrnls Nov 20 '14 at 0:29
  • @wdkrnls, C-j in *scratch* shows no extra info, also e in github.com/abo-abo/lispy. – abo-abo Nov 20 '14 at 10:12
  • 2
    The extra information only appears in the echo area. If you evaluate with C-u C-x C-e to get the output in the current buffer, it does not appear. Isn't that what you do if you wish to insert the result somewhere? – Harald Hanche-Olsen Nov 20 '14 at 16:35
  • @HaraldHanche-Olsen IIUC, he doesn't want to insert it anywhere, he just finds this extra information in the echo area unhelpful and wants to hide it. – Malabarba Nov 21 '14 at 0:34
3

If you don't want a permanent change, you can arrange things with a bit of advice:

(defvar mute-eval-expression-print-format nil
  "Set to t to mute eval-expression-print-format")
(defun mute-eval-expression-print-format (orig-fun value)
  (if mute-eval-expression-print-format
      ""
    (funcall orig-fun value)))
(advice-add 'eval-expression-print-format
        :around #'mute-eval-expression-print-format)

Now set mute-eval-expression-print-format to t in order to mute the extra output.

Note that this uses the new advice mechanism (introduced with emacs 24, I think).

  • Well OP explicitly mentioned emacs 24.4 so it should be good ;-) – syl20bnr Nov 21 '14 at 19:30
  • 1
    @syl20bnr Indeed, but the comment could be useful to others that aren't so up to date. – Harald Hanche-Olsen Nov 21 '14 at 20:19
4

You can override eval-expression-print-format to return "" or nil:

(defun eval-expression-print-format (value)
  ; return an empty string
  "")

See the answer by @Harald Hanche-Olsen for a way to override it temporarily.

  • It's a fine solution, but I'd hardly use the word “temporarily” to describe it. A bit of advice is in order (pun intended); see my answer. – Harald Hanche-Olsen Nov 21 '14 at 7:37
  • @HaraldHanche-Olsen: Fair enough. :-) I'll remove "temporarily" from my answer. – Constantine Nov 21 '14 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.