lispy
lispy copied to clipboard
Make evil-cp themed key bindings more practical
Improvements to evilcp theme, which has originally been created by @ryepesg.
- Duplicate key bindings have been removed.
- Key bindings y, < and > are not bound unconditionally.
- New evilcp-special key theme for barfing and slurping like in evil-cleverparens.
Coverage decreased (-0.01%) to 62.658% when pulling e3deb6c7bbb1186c0529f0cd8f675eca3d63c0bd on Somelauw:evilcp-bindings into 88133cbb34703f6807ac742048be38d547ffd4e7 on abo-abo:master.
Thanks. Seems you rebind a lot of functions in one commit. Could you make a summary of the rebinds, explaining how each one is an improvement?
I don't use evil-cp
theme, but I can merge this commit if I get an OK from @ryepesg or other evil-cp
theme users.
Coverage decreased (-0.01%) to 62.658% when pulling 920a42e318f45406a21ad182d03905c94b1b930d on Somelauw:evilcp-bindings into 88133cbb34703f6807ac742048be38d547ffd4e7 on abo-abo:master.
Coverage decreased (-0.01%) to 62.658% when pulling 920a42e318f45406a21ad182d03905c94b1b930d on Somelauw:evilcp-bindings into 88133cbb34703f6807ac742048be38d547ffd4e7 on abo-abo:master.
I have described the individual changes. One change is that after the pull request keys mostly behave like paredit, whereas originally some keys where double defined. Some people may want the lispy style instead. I have two proposals to solve this.
Proposals:
Make a separate evilcp-lispy and evilcp-paredit theme
evilcp-lispy follows lispy bindings + meta bindings. evilcp-paredit follows paredit bindings + meta bindings.
For example:
(lispy-set-key-theme '(evilcp-special evilcp-lispy c-digits))
;; (lispy-set-key-theme '(evilcp-special evilcp-paredit c-digits))
Make the evil-cp theme stick to M-bindings alone.
Then it can be combined with the themes for paredit, lispy or even parinfer depending on how someone wants [ and ] to behave.
For example
(lispy-set-key-theme '(evilcp-special lispy evilcp c-digits))
;; (lispy-set-key-theme '(evilcp-special paredit evilcp c-digits))
;; (lispy-set-key-theme '(evilcp-special parinfer evilcp c-digits))
The disadvantage is that evil-cp/paredit users may want M-[ and evil-cp/lispy users may want M-} to wrap something in square brackets. I propose "M-[" as a default, because that's what evil-cleverparens uses.
I like the second proposal (Make the evil-cp theme stick to M-bindings alone) and also I agree with M-[
to wrap something in square brackets.
In cases of conflict between themes, the order in which the user select those matters for overriding keybindings. It would be different:
(lispy-set-key-theme '(paredit evil-cp c-digits))
(lispy-set-key-theme '(evil-cp paredit c-digits))
I am not sure if we really need evilcp-special
or if we can just merge it with evil-cp
directly.
@Somelauw @ryepesg Please update the PR once you've agreed on the bindings.
Coverage decreased (-0.01%) to 62.672% when pulling 41737d8df15b0e7c7c68081fd00a16b5e8373168 on Somelauw:evilcp-bindings into f66433837a4ccabcfc7f05d74d7ee8217691d943 on abo-abo:master.
I have added what we agree on so far.
@ryepesg
I am not sure if we really need evilcp-special or if we can just merge it with evil-cp directly.
I don't know about this one. Here are some options:
- Keep evil and evilcp-special apart
- Merge evil and evilcp-special together (evilcp always give you special)
- Automatically use evilcp-special when both evilcp and special are specified
I think 1 is most flexible, but maybe 2 or 3 are simpler.
Maybe evilcp-special can also have some other vim-like bindings like 'y' for lispy-new-copy but then probably another key should be bound to lispy-occur etc.
Coverage decreased (-0.01%) to 62.672% when pulling fc68d23bc459509ac88ed1b8cafb9052d72ce234 on Somelauw:evilcp-bindings into f66433837a4ccabcfc7f05d74d7ee8217691d943 on abo-abo:master.
I have changed DEL to lispy-delete-backward instead of lispy-backward-delete, because I think this function is more intuitive when trying to delete empty strings.
I don't know the finer distinctions between these function, but there seems to be no way with lispy-delete-backward to delete an empty string.
Coverage decreased (-0.01%) to 62.672% when pulling aeff63c52ae416be5409897df84db8c4fb5a526a on Somelauw:evilcp-bindings into f66433837a4ccabcfc7f05d74d7ee8217691d943 on abo-abo:master.
Looking at it again, I think lispy-delete-backward-or-splice-or-slurp and lispy-delete-or-splice-or-slurp are the functions closest to how x and X behave in evil-cleverparens.
What I think is most important about this key theme is the behaviour of < and > in special mode. Having meta-bindings is nice but for evil users these are already defined by evil-cleverparens or by lispyville in normal mode. The rest of the stuff might be a matter of preference, so should maybe not be defined at all or be defined to be as similar to evil-cleverparens as possible.
I have added the bracket pairs back to evilcp. This makes it possible to use evilcp on its own. To make it easier to combine evillcp with lispy, I have changed the priority, so that if evilcp and lispy (or paredit) are both specified the latter gets precedence.
Here are two examples:
;; Behave as much like cleverparens as possible with special bindings
(lispy-set-key-theme evilcp evilcp-special)
;; Combine cleverparens with lispy, so that [ and ] can be used to jump to brackets
(lispy-set-key-theme lispy evilcp evilcp-special)
@ryepesg I think the second one is the one you want. Let me know if this works.
Coverage decreased (-0.01%) to 62.672% when pulling c56a7003e10113aff5ec351ddb175d20ae891f75 on Somelauw:evilcp-bindings into f66433837a4ccabcfc7f05d74d7ee8217691d943 on abo-abo:master.
Looking at it again, I think there is not much point in a lispy-mode-map-evilcp
for the following reasons:
- I think the current theme (before this PR) isn't really usable and I don't think anyone is using it at this moment.
- Bracket rules still need to follow paredit, lispy or parinfer style and evil users have different preferences for this (as discussed). Therefore this key theme should not contain bracket rules.
- evilcp's meta bindings can be added by lispyville. So it's not needed to add them to lispy directly.
(lispyville-set-key-theme
'((additional-movement normal insert emacs)))
- However, with no bracket rules and no meta bindings, this leaves
lispy-mode-map-evilcp
completely empty.
The only thing I think is useful to keep is lispy-mode-map-evilcp-special
. In addition it can optionally have some further changes such as:
- maybe
v
forlispy-mark-list
(becausev
is used in vim for selection) - maybe
y
forlispy-new-copy
(becausey
is used in vim for copying)
Let me know if a new pull request should:
- remove
lispy-mode-map-evilcp
- add
lispy-mode-map-evilcp-special
-
lispy-mode-map-evilcp-special
should make changes other than<
and>
Let me know if a new pull request should:
I don't know if lispy-mode-map-evilcp
is used or relevant anymore. It makes sense to remove it if no one uses it. Please ping the author that introduced it and go ahead with removal if it's fine.
@ryepesg See comment above
We disagree about some configurations, but if I am the only one using evilcp, sure, lets remove it. Also, if you want to use the name evilcp alone (without the "special") feel free to do so.
Please keep making easy for new users to apply their own customisations, so even if a new user has a different view can replace those specific bindings.
@ryepesg If you're still using it, we might as well keep it. Maybe something can be done about the suggestions of @Somelauw that some stuff doesn't work with your theme.
Maybe it's also possible to extract more common stuff from the existing themes to reduce code repetition.
Thank you @abo-abo. For me it is easy to apply my own configurations, so the issue is what is the best for newcomers. Having two similar themes is confusing for them and @Somelauw is a more active contributor, so I think he can continue this tasks forward.