Hello, everyone! I have 2 questions on Evil: 1. How to wipe out all the default key maps which are present in `evil-maps.el' preferably with as few calls as possible? Note that I'm aware of how to do that with 1 by 1 `undefined' assignmetns, but I'm looking for something simpler. 2. Is this (evil-define-key 'normal global-map (kbd "<left>") 'do-something) indentical to (define-key evil-normal-state-map (kbd "<left>") 'do-something) ? Regards, Alexander.
On Fri, Nov 07 2014 (17:59), Alexander Shukaev <[email protected]> wrote:
I have 2 questions on Evil:
1. How to wipe out all the default key maps which are present in `evil-maps.el' preferably with as few calls as possible? Note that I'm aware of how to do that with 1 by 1 `undefined' assignmetns, but I'm looking for something simpler.
Just override the variables: (dolist (map '(evil-normal-state-map evil-emacs-state-map evil-visual-state-map evil-insert-state-map)) (set map (make-sparse-keymap))) There are some maps missing, (apropos "evil.*state-map") will show them to you. Just add those to the list if you want to reset all.
2. Is this
(evil-define-key 'normal global-map (kbd "<left>") 'do-something)
indentical to
(define-key evil-normal-state-map (kbd "<left>") 'do-something)
?
No. The former defines a mapping in an additional keymap for the normal state when `global-map' is active. The latter defines a mapping in the normal state map. This is not only a technical detail but has also consequences on the priority of the mapping (i.e. which definition would shadow). For (evil-)global mappings the latter is preferable, for mode local, e.g. for org-mode, the former is the way to go. Michael
Thank you for explanation. I have another question. What is the purpose of this snippet in `evil-maps.el': ;; evil-read-key (define-key evil-read-key-map (kbd "ESC") #'keyboard-quit) (define-key evil-read-key-map (kbd "C-]") #'keyboard-quit) (define-key evil-read-key-map (kbd "C-q") #'evil-read-quoted-char) (define-key evil-read-key-map (kbd "C-v") #'evil-read-quoted-char) (define-key evil-read-key-map (kbd "C-k") #'evil-read-digraph-char) (define-key evil-read-key-map "\r" "\n") Also some feedback. It does not look right to me that the following code is present in `evil-maps.el' by default: ;;; Minibuffer (define-key minibuffer-local-map "\C-p" 'evil-complete-next) (define-key minibuffer-local-map "\C-n" 'evil-complete-previous) (define-key minibuffer-local-map "\C-x\C-p" 'evil-complete-next-line) (define-key minibuffer-local-map "\C-x\C-n" 'evil-complete-previous-line) I think that modifying any other keymap but `evil-*-map' is not a good idea by default. For instance, now I can't clean it up by simply (dolist (map '(minibuffer-local-map)) (set map (make-sparse-keymap))) since there are other mappings there. Kind regards, Alexander.
On Fr, 2014-11-07 at 21:37 +0100, Alexander Shukaev wrote:
Also some feedback. It does not look right to me that the following code is present in `evil-maps.el' by default:
;;; Minibuffer
(define-key minibuffer-local-map "\C-p" 'evil-complete-next) (define-key minibuffer-local-map "\C-n" 'evil-complete-previous) (define-key minibuffer-local-map "\C-x\C-p" 'evil-complete-next-line) (define-key minibuffer-local-map "\C-x\C-n" 'evil-complete-previous-line)
I think that modifying any other keymap but `evil-*-map' is not a good idea by default.
That is absolutely correct. I removed them in the latest version. No idea why they existed anyway ;) Thanks for pointing out. Best regards, Frank
participants (3)
-
Alexander Shukaev -
Frank Fischer -
Michael Markert