reddit / emacs
How to learn Emacs w/ keybindings changed by Evil?
Zestyclose-Painter-3 · 2022-05-09 07:09
Hi!
One of the things that my baffles me a lot when trying to wrap my head around Emacs - is the keys for some major modes, remapped by Evil.
I'm coming to Emacs from Vim (actually, not Vim per se, but the Vim key bindings that I got so accustomed for over the years that I have them turned on in all my IDE's like PyCharm, etc.), so one the things I installed first was Evil.
But now I've got the problem: for every basic mode I'm trying to understand the major keys are just not there - they are remapped and I don't understand how to easily solve this.
Examples are: my yesterday attempt to learn Emacs debug, with keys explicitly described here:
[https://www.gnu.org/software/emacs/manual/html\_node/elisp/Backtraces.html](https://www.gnu.org/software/emacs/manual/html_node/elisp/Backtraces.html)
[https://www.gnu.org/software/emacs/manual/html\_node/elisp/Debugger-Commands.html](https://www.gnu.org/software/emacs/manual/html_node/elisp/Debugger-Commands.html)
Evil changed most of them, how do I understand to what?..
The same thing happened to me with Dired, Ibuffer and Info!
The only thing that comes to my mind so far is:
1) The official manual (and also the majority of the videos and tutorials) describe the \_keys\_ to press, not the commands behind them. So, somehow, I have to deduce the commands corresponding to that kesy (but C-h k won't work, since the keys are remapped)
2) I have to then find what new key correspond to that command...
I don't really understand how to do that in a general way.
What am I missing here, how to make Emacs + Evil not impossible to learn for a newcomer like me?
karthink · 2022-05-09 07:25
Use non-editing modes like Dired, Ibuffer, Info and Debug in Emacs mode. Either hit `C-z` to enter Emacs mode or configure evil to not be enabled in these modes.
Also, are you using `evil-collection`?
loskutak-the-ptak · 2022-05-09 07:51
You can set the initial state to emacs, like this:
(evil-set-initial-state 'dired-mode 'emacs)
notperm · 2022-05-09 11:30
I’m don’t know about evil but in regular emacs you can just hit C-h m to see all the key bindings for the mode you are in.
F4il3d · 2022-05-09 14:12
You could always byte the bullet and learn to use emacs with its bindings. I have always felt that evil mode is a crutch. The effort maybe a bit more pronounced, but in the long run the rewards will be worth it.
Kyo91 · 2022-05-09 14:18
C-z to drop into Emacs bindings, then describe-key will work as intended. Otherwise I tend to do a lot of describe-command and sorta apropos search what I think it’ll be called and look at the keybindings in the ivy buffer. However, I don’t think this works on more vanilla emacs…
iwaka · 2022-05-09 14:47
>The official manual (and also the majority of the videos and tutorials) describe the _keys_ to press, not the commands behind them.
Yes, that's a real pain point for an editor that prides itself on its *customisability*.
What I would do in these situations is switch to Emacs mode (C-z), then find out the function name (C-h k, then the keybinding in your tutorial). Emacs would then show me what keys (if any) the function was bound to in evil. Most importantly, I'd know the actual *name* of the function, which is what the manuals and tutorials should be providing in the first place! /rant
Stay strong.
frozeninfate · 2022-05-09 16:01
I use which-key which helps discover keybinds
xtifr · 2022-05-09 18:19
Doesn't the menu still work? You should be able to browse the mode options (and, incidentally, see their bindings), as well as access all the regular help options through the menu. Even if both `C-h k` *and* `F1 k` have been remapped, you should still be able to click "Help->Describe->Describe key or mouse operation", which is the same thing.
Icommentedtoday · 2022-05-09 18:28
It would be so handy if there is an interactive command that does it automatically:
- asks you to press a default keybind
- it shows which command it is set to and shows the keybind you configured
Is this even possible though? I guess you could get a list of default bindings but that changes for each mode too
7890yuiop · 2022-05-10 08:08
I presume such a command would disable evil (if it was active), `(call-interactively #'describe-key)`, and then re-enable evil (if it had originally been enabled).
I don't use evil so I don't know what the disable/enable/status functions are, but it should be extremely easy to write this command. (And if you think it's useful, submit it upstream.)
Icommentedtoday · 2022-05-10 10:09
Indeed something like that could be done, but I'm envisioning more of a general command that works regardless of evil. So even if you change non-evil keybinds it would work
7890yuiop · 2022-05-10 12:08
Emacs doesn't remember the history of keymaps. If you clobber a binding directly or otherwise manipulate a keymap, there's no memory of what it used to be or rollback option. But even if it did remember, `describe-key` is still processing the active keymaps at the time you call it, so it's not just a question of the bindings you've changed, but also the modes you've enabled, etc.
I would go after the low-hanging fruit, as my suggestion is very easy, and yours sounds rather hard.
Icommentedtoday · 2022-05-11 15:58
That's why I doubted that it was possible :D
dpoggio · 2022-05-14 05:41
The manual is FDL and evil is GPL. Most of the manual includes function names, as stated [here](https://www.gnu.org/software/emacs/manual/html_node/emacs/Commands.html). If you feel something can be enhanced, there are plenty of channels to collaborate, as Emacs is a community effort, and so is it’s manual.
I would blame evil folks if some Emacs’s documented feature gets replaced by some undocumented thing. At most, they could’ve helped with the Emacs manual so that people like you are not left alone.
Now, I can run things like `C-h m` and `C-h i` from inside Emacs, so: why do you propose such a weird way of doing the exact same thing?
iwaka · 2022-05-17 05:55
> Now, I can run things like C-h m and C-h i from inside Emacs, so: why do you propose such a weird way of doing the exact same thing?
I don't see how that relates to the problem in question. I take it you do not use evil, and are not familiar with the woes of it being a second-class citizen. The method I describe is useful for evil users who only know the default Emacs keybinding of a command, and want to find out the function name and the corresponding evil keybinding.
dpoggio · 2022-05-18 15:57
I wanted to say from inside Evil. And it’s not about being “a second class citizen”. Evil is a mode you choose to have altering Emacs’s behavior. The docs are ours, a community effort, and if vanilla behavior is well documented, it’s because most of the community uses it. You don’t, so you can either fix what you think is not okay with the current documentation (it’s not much), or ask Evil authors to have better documentation for their extension.