Search code examples
emacskeyboard-shortcutselisp

Conflicting keyboard shortcuts in two Emacs minor modes


I have an ErgoEmacs minor mode turned on globally, which defines many custom keyboard shortcuts for basic editing. However when I open any lisp file, slime-mode turns on automatically and overrides M-p and M-n with its own commands. However I want M-p and M-n to be always defined by ergoemacs-mode. How do I set up order in which minor modes load and define keybindings? Or how do I raise ergoemacs-mode keybindings priority?


Solution

  • Maybe a simpler solution is to remove Slime's bindings:

    (add-hook 'slime-mode-hook
      (lambda ()
        (define-key slime-mode-map [?\M-p] nil)
        (define-key slime-mode-map [?\M-n] nil)))
    

    Beware: guarantedd 100% untested, the variable's name might be different from slime-mode-map (and it probably will only exist after loading slime-mode).