noctuid / evil-guide

Draft of a guide for using emacs with evil
GNU General Public License v3.0
1.26k stars 61 forks source link

There definitely is leader functionality in evil #2

Closed ajarara closed 8 years ago

ajarara commented 8 years ago

There is an evil-leader package, (which you can argue is not a good enough solution because it's not maintained anymore)

but it's quite easy to build your own leader-key functionality even without this package:

(defvar my-leader-map
  (make-sparse-keymap)
  "Keymap for 'leader key' shortcuts.")
(evil-define-key 'normal global-map "," my-leader-map)
(define-key my-leader-map " " 'whitespace-cleanup)
(define-key my-leader-map "b" 'list-buffers)

taken from: https://github.com/cofi/evil-leader/issues/36

I happen to use evil-leader (definitely considering dropping it now that I realize it's been inactive, but until I find a showstopping bug, I'll keep it around) and find nothing wrong with it. It works with which-key (because it uses a keymap under the hood anyway), which yeah is kinda mundane since you should be aware of what your binds do, and has a neat interface for adding keys to the existing emacs session (M-x evil-leader/set-key[-for-mode])

I can write a pull req if you'd like.

Uh, wait a minute, you wrote general.el partly as a replacement for evil-leader. Why not at least mention the two?

noctuid commented 8 years ago

My point was that there isn't an exact equivalent of vim's <leader>. I mention general.el in several places including the leader section. I could maybe also mention prefix maps in that section and give an example that doesn't use any packages if that would make things clearer.

ajarara commented 8 years ago

Sure, if you'd like. Out of curiosity, what functionality is missing?

noctuid commented 8 years ago

There isn't any functionality missing. The common ways of having named prefixes in emacs are actually more powerful than vim's <leader>, but because there isn't a standard <leader> equivalent (something like evil-leader-map), there aren't emacs packages that will bind keys under your "leader" key. Well.. I am aware of one (evil-org), but the fact that it requires the use of evil-leader was reason enough for one user to create an alternative package (called syndicate).

I don't know if I would call this difference a definite downside though. I occasionally ran into issues where some vim plugin would override one of my personal <leader> keybindings.

I've tried to better clarify what I meant. Let me know if you think I should add anything else.

ajarara commented 8 years ago

Thanks for the balanced insight!