0
votes

When in *scratch*, C-j calls eval-print-last-sexp. However, I can't get the default behavior when I do this:

(local-set-key
 (kbd "C-j") 
 (lambda()(interactive) (eval-print-last-sexp)))

Now when evaluation result is integer, its octal and hex representations are printed as well:

(+ 2 2)
4 (#o4, #x4)

What is the cause of this behavior and how can I turn it off?

1

1 Answers

2
votes

The additional output comes from the function eval-expression-print-format (which see). In lisp-interaction-mode the variable this-command is set to eval-expression-print-format. You just need to set it similarly:

(local-set-key
 (kbd "C-j") 
 (lambda()(interactive)
 (setq this-command 'eval-last-sexp)
 (eval-print-last-sexp)))