evil-lion icon indicating copy to clipboard operation
evil-lion copied to clipboard

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

Open tmalsburg opened this issue 7 years ago • 5 comments

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.

tmalsburg avatar Mar 27 '17 16:03 tmalsburg

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.

edkolev avatar Mar 28 '17 07:03 edkolev

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".

ninrod avatar Mar 28 '17 11:03 ninrod

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

tmalsburg avatar Mar 28 '17 19:03 tmalsburg

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.

tmalsburg avatar Mar 28 '17 19:03 tmalsburg

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 avatar Mar 29 '17 06:03 edkolev