Fork me on GitHub
#emacs
<
2016-02-08
>
bozhidar08:02:37

you can add a condition in your hook function

bozhidar09:02:29

e.g. (if (eq this-command …))

bozhidar09:02:51

this-command refers to the interactive command you’re current executing

bozhidar09:02:12

and by hook function

bozhidar09:02:21

I actually meant keybinding

bozhidar09:02:37

instead of mapping RET directly to paredit-newline

bozhidar09:02:06

you can map it some lambda with a bit of logic inside it

anmonteiro10:02:48

@bozhidar: thanks, but I've found an alternative solution. It seems this is working nicely:

(eval-after-load 'paredit
  #'(define-key paredit-mode-map [remap newline-and-indent] 'paredit-newline))

bozhidar10:02:08

#’ is not necessary

anmonteiro10:02:30

I'll remove it. I'm still not very familiar with the EL syntax

anmonteiro10:02:54

@bozhidar: it seems that # wasn't necessary, but if I omit the ' emacs will complain the following: Symbol's value as variable is void: paredit-mode-map

bozhidar10:02:30

yeah, this slipped my mind

anmonteiro10:02:35

seems like # is just backwards compatibility with older emacs versions?

malabarba11:02:40

No. #' is for quoting functions. It's not strictly necessary, but it's a good habit.