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.) Oh, using (define-key evil-normal-state-local-map "((" 'evil-paredit-backward-slurp-sexp) seems to work. So is that the preferred way of solving this situation?
On Fri, Sep 19, 2014 at 10:01 PM, Nikolai Weibull <[email protected]> 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…
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 <[email protected]> wrote:
On Fri, Sep 19, 2014 at 10:01 PM, Nikolai Weibull <[email protected]> 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 [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
On Sat, Sep 20, 2014 at 6:22 PM, Gordon Gustafson <[email protected]> wrote:
Try putting this before your other bindings:
(define-key evil-motion-state-map "(" nil) (define-key evil-motion-state-map ")" nil)
That will remove the global binding in all buffers.
Correct, but I'm still curious if it helps your situation. If it does, we can restore the default () bindings whenever you don't want to use paredit mode in a change-mode-hook (or whatever that hook is called) On Sep 21, 2014 6:55 AM, "Nikolai Weibull" <[email protected]> wrote:
On Sat, Sep 20, 2014 at 6:22 PM, Gordon Gustafson <[email protected]> wrote:
Try putting this before your other bindings:
(define-key evil-motion-state-map "(" nil) (define-key evil-motion-state-map ")" nil)
That will remove the global binding in all buffers.
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
On Sun, Sep 21, 2014 at 3:43 PM, Gordon Gustafson <[email protected]> wrote:
Correct, but I'm still curious if it helps your situation. If it does, we can restore the default () bindings whenever you don't want to use paredit mode in a change-mode-hook (or whatever that hook is called)
That doesn’t sound like a viable solution. What I instead did was (defun evil-paredit-enter-and-exit-motion-state-to-set-keys () (evil-motion-state) (evil-normal-state)) (add-hook 'paredit-mode-hook 'evil-paredit-enter-and-exit-motion-state-to-set-keys) This seems to enable the keys bound in motion state, while still leaving me in normal state. Not sure at all why this works, but it works.
participants (2)
-
Gordon Gustafson -
Nikolai Weibull