Mapping ( and ) in paredit mode

Gordon Gustafson gordon3.14 at gmail.com
Sat Sep 20 18:22:11 CEST 2014


Try putting this before your other bindings:

(define-key evil-motion-state-map "(" nil)
(define-key evil-motion-state-map ")" nil)

I'm not sure if you can have a binding for "(" AND use it as a prefix
key. If that fixes things, we can look for a solution that still lets
you use "(" and ")" normally when paredit-mode isn't active. If not,
we'll delve into the map hierarchy that you've already started to
discover.

On 9/19/14, Nikolai Weibull <now at disu.se> wrote:
> 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...
>
> _______________________________________________
> implementations-list mailing list
> implementations-list at lists.ourproject.org
> https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
>



More information about the implementations-list mailing list