Fork me on GitHub
#emacs
<
2021-07-20
>
Jason07:07:33

Hey guys, so I’m new to emacs and I’m coming from a vim background. I’ve install doom emacs and it’s great definitely got me up and going much quicker than I would have otherwise but there is a couple of niggle things I’d still like to change. Ideally I want to change some of the evil mode bindings, swapping ; and : for instance, but emacs seems to have a rather complicated way of setting that up as far as I can tell. Could anyone point me in the right direction?

djm07:07:14

For Doom, isn’t it a case of putting (define-key! ";" #'whatever) in ~/.doom.d/config.el? (Unless Doom has rebound C-h c, you can use C-h c : to find out what command : is currently sending… otherwise M-x describe-key-briefly, followed by :)

djm07:07:50

(Disclaimer: I have played with Doom a little, but am not a Doom user)

djm07:07:03

Oh, I guess it’s different for evil mode stuff, just a second

Jason07:07:43

Yeah honestly I have no idea 😅 I’ve been googling for a few hours on it and I’m finding it really hard to just find any definitive way to do it

Jason07:07:35

Or maybe it’s that there is so much information about doing it that I don’t feel confident doing any of them..

djm07:07:58

https://github.com/hlissner/doom-emacs/blob/develop/modules/config/default/+evil-bindings.el has

(map! :leader
      :desc "Eval expression"       ";"    #'pp-eval-expression
      :desc "M-x"                   ":"    #'execute-extended-command
...

djm07:07:04

So if those are the ones you want to swap, you should be able to copy that into your config.el, and change it

djm07:07:52

The evil but non-doom way is with evil-define-key, by the looks of it

Jason07:07:56

Okay cool, so how do you figure that out then?

djm07:07:41

How do you figure out how to use evil-define-key, or..?

Jason07:07:30

I guess what I’m asking is how do you find where the keybindings are defined

Jason07:07:48

So if I was to do this with a completely unrelated keybinding where would I start to figure out how to rebind it?

djm07:07:03

C-h k (`describe-key`) should tell you where something’s defined

Jason07:07:09

Okay that tells me the function it calls but not the actual binding, right?

djm07:07:57

Evil also provides evil-global-set-key, which is what you want here, I think: (evil-global-set-key 'normal ";" 'execute-extended-command), if you want to use evil’s mechanism, rather than Doom’s

djm07:07:31

describe-key should tell you everything

Jason07:07:32

See this is confusing part with emacs there can be multiple ways to do things 😅

djm07:07:37

It doesn’t give you the exact elisp, but it tells you the keys, the command, the map, and the file

Jason07:07:06

Is there a way to get the exact elisp?

Jason07:07:33

Or is this just something I’m going to have to struggle with every time

djm07:07:55

Oh, sorry, it tells you the file that the command/function is from, not the keybinding

djm07:07:14

You can probably find that by grepping in ~/.emacs.d

Jason07:07:11

Ahh yeah, good plan

djm07:07:48

In this case there are multiple ways of doing it because you’ve added Doom onto Emacs, and Doom is using evil mode - so you have to learn some combination of emacs, doom and evil mode

Jason07:07:50

I imagine what I’d do is just copy whatever binding I find and replace it how I want it. That is until I start to understand it a little more

djm07:07:05

Yeah, it’ll get easier

Jason07:07:31

Well awesome, thank you so much 🙇

djm07:07:54

Doom changes the learning curve, I guess - you get a nice setup out of the box, that’s both easier and harder to customise

djm07:07:56

Good luck!

Jason07:07:54

Yeah part of the reason I choose it is that I can get going quicker but I might downgrade later on when I understand things more

👍 2
grazfather15:07:06

I really recommend you join the doom discord, they are super helpful over there.

👀 2