0

I'm trying to create a different keybinding to abort a commit in magit. Right now, when you're editing a commit message C-c C-k is bound to with-editor-cancel, which does the trick. But I'm an evil user and prefer vim-style keybindings, and I actually use evil-escape to set most of my bail-out keybindings to ESC ESC.

My first thought was to just provide a different keybinding for with-editor-cancel, like to bind it in normal state to ESC ESC to match the rest of my escape keys. But here's the problem: Magit commit edit buffers appear to run under text major mode which a bunch of other modes I use constantly inherit from (markdown, org, etc.) And with-editor-cancel appears to be super-dangerous to have bound to a key normally. I tried it out on an org file just to see what would happen, and it not only killed the buffer without any confirmation, but also deleted the underlying file from the file system (!!!). This is not something I want to accidentally call.

So, like, is there some way to define a keybinding only on those text-mode buffers that happen to have been created by magit?

(Most of my keybindings are defined with general, but I'm happy to do it some other way.)

1 Answer 1

2

But here's the problem: Magit commit edit buffers appear to run under text major mode

See C-hv git-commit-major-mode

You can use define-derived-mode to make a custom major mode, and define bindings for that major mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.