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

Adds the evil-remap package to spacemacs layers #5465

Closed
wants to merge 1 commit into from

Conversation

calebmeyer
Copy link

Rationale

Spacemacs is intended (at least in part) for vimmers who have
never used emacs, but may already be very comfortable in vim. Often one
of the first things you learn in vim is to put something like
imap jj <Esc> " use jj for returning to normal mode
in your .vimrc

Spacemacs already covers this case pretty well, but there are lots of
other changes you might want to make. Another common one:
nnoremap ; : " set ; to summon ex-mode

Unfortunately, today there are many ways to set a keybinding in emacs.
global-set-key, local-set-key, define-key, etc. Worse still, most of the
documentation online doesn't take evil into account. Also, keys aren't
defined simply, via a string. You have to use (kbd "blah") instead.I
personally ran into this problem when starting with spacemacs. I wanted
to map a key in normal mode, but global-set-key was getting overridden
by the already defined behavior of that key in normal mode (a more
specific binding).

Evil-remap allows vim-users to bind keys simply. The functions all
follow the same format as vim:
<mapping_type> <key to map> <behavior to map it to>

Implementation

This layer is very simple, since it's my first foray into emacs lisp.
Based on the documentation for creating a layer, I took the package
definition from my additional-packages and changed the require call to
be a use-package call. I also added documentation based on the
documentation on the package itself. I tested it locally in my private
layers, then moved it to make this PR.

Spacemacs is intended (at least in part) for vimmers who have
never used emacs, but may already be very comfortable in vim. Often one
of the first things you learn in vim is to put something like
`imap jj <Esc> " use jj for returning to normal mode`
in their .vimrc

Spacemacs already covers this case pretty well, but there are lots of
other changes you might want to make. Another common one:
`nnoremap ; : " set ; to summon ex-mode`

Unfortunately, today there are many ways to set a keybinding in emacs.
global-set-key, local-set-key, define-key, etc. Worse still, most of the
documentation online doesn't take evil into account. Also, keys aren't
defined simply, via a string. You have to use (kbd "blah") instead.I
personally ran into this problem when starting with spacemacs. I wanted
to map a key in normal mode, but global-set-key was getting overridden
by the already defined behavior of that key in normal mode (a more
specific binding).

Evil-remap allows vim-users to bind keys simply. The functions all
follow the same format as vim:
<mapping_type> <key to map> <behavior to map it to>

This layer is very simple, since it's my first foray into emacs lisp.
Based on the documentation for creating a layer, I took the package
definition from my additional-packages and changed the require call to
be a use-package call. I also added documentation based on the
documentation on the package itself. I tested it locally in my private
layers, then moved it to make this PR.
@syl20bnr
Copy link
Owner

Thank you for the PR.

I'm not sure about this package because I feel that it does not serve the user well in the end for at least these reasons:

  • the first obviously is that it hides one the most important things to learn in Emacs which is how to configure key bindings.
  • then what are the limits of this package ? Is it complete enough to avoid violation of POLA for Spacemacs users ?
  • Evil has the properties to be a pretty complete Vim UX emulation and to be an extensible layer. Does this cover the additional Evil states we have like iedit ?
  • the package is young and we should be extra careful to propose it officially.

@calebmeyer
Copy link
Author

the first obviously is that it hides one the most important things to learn in Emacs which is how to configure key bindings.

Do we have good documentation surrounding this today? If not, that may be a good alternative to this. One of the most common beginner questions on gitter is "How can I bind x function to y keys, in z modes?"

then what are the limits of this package ? Is it complete enough to avoid violation of POLA for Spacemacs users ?

Huh, I've always heard it as the principle of least surprise. Threw me for a second. I'm not sure I understand the package well enough to answer this one.

Evil has the properties to be a pretty complete Vim UX emulation and to be an extensible layer. Does this cover the additional Evil states we have like iedit?

It does not.

the package is young and we should be extra careful to propose it officially.

Yeah, someone recommended on gitter that if I was going to use the package that I should make a layer of it :) It was a pain to set up manually, since all the other packages I've used have been on Melpa or elpa, and since I had to explicitly (require 'evil-remap) in my dotfile before I could use it.

@a13ph
Copy link

a13ph commented Mar 16, 2016

solves #5426 <3

@Kazark
Copy link
Contributor

Kazark commented Apr 17, 2018

Given that this has not been merged, how does one go about nnoremap ; :? I am brand-new to Spacemacs and my muscle-memory is screwing me without this.

@sdwolfz
Copy link
Collaborator

sdwolfz commented Apr 17, 2018

@Kazark There is an example in the PR itself.

(define-key evil-normal-state-map (kbd ";") 'evil-ex)

Put this inside dotspacemacs/user-config.

@Kazark
Copy link
Contributor

Kazark commented Apr 17, 2018

@sdwolfz Thanks. That's the bootstrapping I needed as a complete n00b. One of the things I am looking forward to here is a chance to dive a little deeper into Lisp. I would much rather work in Lisp than VimScript, despite being moderately good at VimScript, which is one of the things that attracts me to Spacemacs. I am a diehard functional programmer, but have lamentably little experience with Lisps. Anyhow, thanks.

@github-actions
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this PR is still need merging!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Sep 30, 2020
@github-actions github-actions bot closed this Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Layer stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants