Conflicting keyboard shortcuts in two small Emacs modes

I have an ErgoEmacs helper mode that defines many custom keyboard shortcuts for basic editing. However, when I open any lisp file, slime-mode is enabled automatically and overrides M-pand M-nwith its own commands. However, I want M-pand M-nalways be defined using ergoemacs mode. How do I customize the order in which minor modes are loaded and define key bindings? Or how to increase the priority of key bindings in ergoemacs mode?

+3


source to share


2 answers


Perhaps a simpler solution is to remove the Slime bindings:

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

      



Beware: guaranteed 100% untested, variable name may differ from slime-mode-map (and will probably only exist after slime-mode is loaded).

+2


source


How do I customize the order in which minor modes are loaded and define key bindings? Or how to increase the priority of key bindings in ergoemacs mode?

I think you need to make sure ErgoEmacs appears before slime-mode in the variable minor-mode-map-alist

. There's probably a much better way, but the code below should achieve this. Let me know if it does what you want.



(require 'cl)

(add-hook
 'slime-mode-hook
 (lambda ()
    (let ((elem (first
         (remove-if-not
          (lambda (item) (equal 'ergoemacs-mode (car item)))
          minor-mode-map-alist))))
      (setq minor-mode-map-alist (remove elem minor-mode-map-alist))
      (add-to-list 'minor-mode-map-alist elem))))

+3


source







All Articles