2

I've searched for this before but I've only seen questions like the below:

I don't have an understanding of what a major / minor mode really is (which both questions reference) (or whether it's relevant).


I'm trying to redefine the - key when I'm editing any file. It's currently defined by the evil-mode package in:

evil-maps.el:

243:(define-key evil-motion-state-map "-" 'evil-previous-line-first-non-blank)

How would I go about redefining this to instead run a other function? What are my options - and their implications?

I've managed to what I assume redefines the key binding by adding the following to my .spacemacs user-config:

  (define-key evil-motion-state-map "-" 'deer)

Which works, but it feels a bit hacky / cumbersome in case it ever conflicts with a future key binding with another package.

1
  • The question is unclear, to me. You give an example (with deer) that you say works, and that looks like it would work (assuming there is a command deer). But you still have a question. What's the question, exactly?
    – Drew
    Dec 27, 2018 at 3:04

1 Answer 1

2

You might want to take a look at the General.el, which, as far as I know, was designed to work coherently with evil. Here are the examples for evil bindings.

This is what might be relevant for you in terms of specifying both evil state and emacs major mode:

(general-define-key
 :states ''motion
 :keymaps 'emacs-lisp-mode-map
 "-" 'deer)

Your Answer

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

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