Emacs key-bindings: (dired) mode overwrites the secondary key map?

Even after everything that was given in the Global Override of Key Binding in Emacs, I still could not get it to work.

I linked Mo to another window in my global key map as follows:

(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.") (define-key my-keys-minor-mode-map "\Mo" 'other-window) (define-minor-mode my-keys-minor-mode "A minor mode so that my key settings override annoying major modes." t " my-keys" 'my-keys-minor-mode-map) (my-keys-minor-mode 1) (defun my-minibuffer-setup-hook () (my-keys-minor-mode 0)) (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook) ;; Maintain the above keymap even after loading a new library (defadvice load (after give-my-keybindings-priority) "Try to ensure that my keybindings always have priority." (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode)) (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist))) (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist) (add-to-list 'minor-mode-map-alist mykeys)))) (ad-activate 'load) 

but dired mode cancels this and redirects it to dired-omit-mode .

What am I missing?

+4
source share
1 answer

Your minor mode is defined as buffer-local. You can define it as global, for example:

 (define-minor-mode my-keys-minor-mode "A minor mode so that my key settings override annoying major modes." :global t :lighter " my-keys") 

But then your my-minibuffer-setup-hook will disable it also globally. Also, if it is global, and you basically always turn it on, you can omit :lighter " my-keys" , so your mode line does not fill up unnecessarily.

+3
source

Source: https://habr.com/ru/post/1435422/


All Articles