I like using C-j
to eval-last-sexp
but paredit-mode (which I otherwise like) overrides this to paredit-newline
. Looking in the paredit-mode docs I don't see anything like a paredit-mode-hook
defined where I can add-hook
to call local-set-key
or a similar function.
Anyone have a suggestion?
Update
After trying out the two answers below and not having much success, I think the problem may be related to the fact that paredit is getting loaded in a few different contexts? To wit, I am opening both Common Lisp, Clojure and Emacs Lisp files, all of which can use paredit. Sadly, the various forms of eval-last-sexp
have slightly different names in each mode, so I can't define the key once for everything. Rather, I need to bind the key based on the major mode that I am in also. Hopefully that adds another useful data point.
No need to use hooks, something like the following should work:
(eval-after-load "paredit"
#'(define-key paredit-mode-map (kbd "C-j") 'eval-last-sexp))
Alternatively, if for some reason that doesn't work, or you simply prefer the use of hooks, you can add the above define-key
invocation to the hooks of the major modes for which paredit
is activated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With