Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode? How to best integrate evil-lion with evil and not lose flexibility #8

Open
tmalsburg opened this issue Mar 27, 2017 · 5 comments

Comments

@tmalsburg
Copy link

This is such a great feature. One of those things that you've always missed without knowing it. One question, though: Does it make sense that this has it's own mode? I would guess that users want this when evil mode is on but not otherwise. Making this its own mode means that it can be switched on with evil off and the reverse. Not sure if there are any use cases for these combinations.

@edkolev
Copy link
Owner

edkolev commented Mar 28, 2017

Glad you like it! I had the same reaction when I first discovered vim-lion.

Regarding the mode - at this point, I've spent (at least) twice as much time on figuring out how to package this functionality for evil versus time I've spent developing it.

Different people use evil differently - some use it for prog/text modes only, some use it everywhere, some use emacs-state instead of insert-state.

Looking at different packages, I don't see a single convention that evil-lion can follow:

  • evil-replace-with-register: (evil-replace-with-register-install)
  • evil-exchange: (evil-exchange-install) or (evil-exchange-install)
  • evil-surround: (global-evil-surround-mode 1)
  • evil-visual-star (global-evil-visualstar-mode)

Trying to package evil-lion as a mode has its quirks as well - now it's a global minor mode, but doesn't have a local mode companion (as a result you can't enable the local mode in a prog-mode hook); this is easily fixed by defining it as a local mode and using emacs' define-globalized-minor-mode, but then it doesn't work for fresh buffers in fundamental mode (created with :new for example) as described in the docs

My goals seem so simple (to me at least), yet I haven't found a way to cover them all in a clean fashion:

  1. there should be a simple way to enable evil-lion - this is what the mode (evil-lion-mode) tries to achieve; I guess most of the users will just add this and be done with it
  2. there should be a way to enable evil-lion in certain modes only (so it doesn't screw magit-status for example)
  3. there should be a way to customize the bindings (e.g. ga instead of gl)

In other words, I'm more than open for suggestions.

@ninrod
Copy link

ninrod commented Mar 28, 2017

Hi, please allow me to chime in.

at it's core, evil-lion is composed of just 2 commands. to use evil-lion, the user just have to bind those commands to convenient keybindings.

So turning off evil-lion should be just a matter of unbinding those keys. the minor mode does just that: binds and unbinds the default keybindings.

I find this simple and effective enough. "just works".

@tmalsburg
Copy link
Author

Yes, it's easy but not having to think about switching evil-lion on would be even easier.

@tmalsburg
Copy link
Author

Yes, it's easy to switch on evil-lion-mode but it's not "just works" easy. That would be if the user didn't have to bother at all about activating evil-lion. Anyway, it's not a big deal and I see now that this issue may be a bit more complex than I appreciated. Probably best to stick with the current approach.

@edkolev
Copy link
Owner

edkolev commented Mar 29, 2017

Here's yet another way you can bind the 2 commands with the added benefit of autoloading evil-lion on first use:

(use-package evil-lion
  :ensure t
  :bind (:map evil-normal-state-map
         ("g l " . evil-lion-left)
         ("g L " . evil-lion-right)
         :map evil-visual-state-map
         ("g l " . evil-lion-left)
         ("g L " . evil-lion-right))

I believe this could be made even shorter with general.el

With this approach you never have to enable the minor mode. But it has the drawback of being active in non prog-mode buffers like magit.

I'll leave this issue open for a bit, just in case someone comes up with some other option.

@edkolev edkolev reopened this Mar 29, 2017
@edkolev edkolev changed the title Mode? Mode? How to integrate evil-lion with evil Mar 29, 2017
@edkolev edkolev changed the title Mode? How to integrate evil-lion with evil Mode? How to simply integrate evil-lion with evil and not lose flexibility Mar 29, 2017
@edkolev edkolev changed the title Mode? How to simply integrate evil-lion with evil and not lose flexibility Mode? How to best integrate evil-lion with evil and not lose flexibility Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants