1
votes

I'm new to emacs so I need simple tip. I'd like to use Command-RET to eval last expression - to do this:

clojure-mode.el:

(define-key map "\C-x\C-e" 'lisp-eval-last-sexp)

And I don't want to change original clojure-mode.el file. How can I define key binding that will execute C-x\C-e and that will call 'lisp-eval-last-sexp? It would be great solution for me, because I can't bind Command-RET directly with:

local-set-key

to 'lisp-eval-last-sexp, emacs can't find this function.

thanks in advance, Bartek

Update:

finally it turned out that I needed to write:

M-x
describe-key
^X ^E

and it returned me:

^X ^E runs the command slime-eval-last-expression, which is an
interactive Lisp function in `slime.el'.

It is bound to ^X ^E, <menu-bar> <SLIME> <Evaluation> <Eval Last
Expression>, <A-return>.

(slime-eval-last-expression)

Evaluate the expression preceding point.

[back]

and then I bound my keys to function

'slime-eval-last-expression

thanks for your help :)

2
Ir should be eval-last-sexp not lisp-eval-last-sexp?Miserable Variable
nope, It's not working the same waybartek
See answer below. Try eval-print-last-sexp, that is what C-j is bound to in my emacs.ditkin

2 Answers

2
votes

You can rebind keys in your .emacs file you don't need to change clojure-mode.el,

(add-hook 'clojure-mode-hook
                '(lambda ()
                   (define-key clojure-mode-map 
                     "\e\C-x" 'lisp-eval-defun)))
1
votes

I believe you want to set it to eval-print-last-sexp instead. That is what C-j is bound to.