Mapping ( and ) in paredit mode

Nikolai Weibull now at disu.se
Fri Sep 19 23:04:16 CEST 2014


On Fri, Sep 19, 2014 at 10:01 PM, Nikolai Weibull <now at disu.se> wrote:
> Hi!
>
> I would like to map ( and ) as prefix keys to various other mappings
> to paredit mode functions:
>
> (evil-define-key 'normal paredit-mode-map
>   "((" 'evil-paredit-backward-slurp-sexp
>   "))" 'evil-paredit-forward-slurp-sexp
>   ...)
>
> This only works after a while for inexplicable reasons when you’ve
> clicked around a bit and tried to execute a couple of mappings in a
> buffer with Paredit enabled.  The problem is that ( is mapped to
> backward-sentence in evil-motion-state-map, which seems to take
> precedence.
>
> How do I go about removing the mapping of ( to backward-sentence in
> evil-motion-state-map for buffers that have Paredit enabled?
>
> (I’m sure that this worked without any issues before, but I’ve changed
> my configuration somewhat and now I get this weird behavior.)

So after some further thinking (which I should have done from the
start), it’s obvious that one needs to do

(add-hook 'paredit-mode-hook
               (lambda ()
                 (define-key evil-normal-state-local-map "))"
'evil-paredit-forward-slurp-sexp)))

to get it to work, as that’s the only map that precedes
evil-normal-state-map.  This raises the question of how to override a
keybinding defined in evil-normal-state-map with a command that should
be in a evil-motion-state-local-map, for example,

                 (define-key evil-motion-state-local-map "gw"
'evil-paredit-forward)

as evil-motion-state-local-map has lower precedence than
evil-normal-state-map.  Why is that so?  Shouldn’t the order be
evil-normal-state-local-map, evil-motion-state-local-map,
evil-normal-state-map, evil-motion-state-map when in normal state?

I’m surely missing something, and it confuses me to no end that this
worked with a simple evil-define-key before (and looking at
evil-paredit, it seems to be working for similar cases there:
https://github.com/roman/evil-paredit/blob/master/evil-paredit.el –
how can the binding of paredit-forward-delete there override the
binding of evil-delete-char in evil-normal-state-map?).

I’m really sorry to put you all through this blurb, but I feel like
I’m losing my mind trying to understand what’s going on…



More information about the implementations-list mailing list