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?

Drew
  • 75,699
  • 9
  • 109
  • 225
wdkrnls
  • 3,657
  • 2
  • 27
  • 46
  • When you say "evaluate", do you mean C-x C-e? – Malabarba Nov 20 '14 at 00: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 00:29
  • @wdkrnls, `C-j` in `*scratch*` shows no extra info, also `e` in https://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 00:34

2 Answers2

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.

Constantine
  • 9,072
  • 1
  • 34
  • 49
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).

Harald Hanche-Olsen
  • 2,401
  • 12
  • 15