From a044861d6b20a60886bea8d0a22cabdd5ab2815d Mon Sep 17 00:00:00 2001 From: Chris Hughes Date: Tue, 9 Jan 2024 19:38:48 -0400 Subject: [PATCH 1/2] Added clarification to evil-define-key for escaping modifier keys It is useful to have clarification in the doc string for evil-define-key that it is necessary to escape modifiers keys for users that are accustomed to using functions like global-set-key or keymap-global-set where this is not necessary. This is also not made particularly clear in the define-key function itself, which is a legacy function. --- evil-core.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/evil-core.el b/evil-core.el index 41909977..cd9a40f5 100644 --- a/evil-core.el +++ b/evil-core.el @@ -958,7 +958,13 @@ the following lead to identical bindings: The symbol `local' may also be used, which corresponds to using `evil-local-set-key'. If a quoted symbol is used that is not `global' or `local', it is assumed to be the name of a minor -mode, in which case `evil-define-minor-mode-key' is used." +mode, in which case `evil-define-minor-mode-key' is used. + +Bindings that use modifier keys such as `C' or `M' must be escaped +with a `\\' character as this is a requirement of the `define-key' +function. For example: + + (evil-define-key \\='normal foo-map \"\\C-a\" \\='bar)" (declare (indent defun)) (cond ((member keymap '('global 'local)) From a9e465148bdc08ec033fcff8b1fd3802b8bb09e6 Mon Sep 17 00:00:00 2001 From: Chris Hughes Date: Wed, 10 Jan 2024 23:50:01 -0400 Subject: [PATCH 2/2] Fixed poor wording and used kdb in place of escape sequence --- evil-core.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/evil-core.el b/evil-core.el index cd9a40f5..614d8ea7 100644 --- a/evil-core.el +++ b/evil-core.el @@ -960,11 +960,12 @@ The symbol `local' may also be used, which corresponds to using `global' or `local', it is assumed to be the name of a minor mode, in which case `evil-define-minor-mode-key' is used. -Bindings that use modifier keys such as `C' or `M' must be escaped -with a `\\' character as this is a requirement of the `define-key' -function. For example: +KEY is an internal Emacs representation of a key, as for +`define-key'. To bind key sequences that use modifier keys such +as \"C-a\" or \"M-a\", convert the key sequences using `kbd'. +For example: - (evil-define-key \\='normal foo-map \"\\C-a\" \\='bar)" + (evil-define-key \\='normal foo-map (kbd \"C-a\") \\='bar)" (declare (indent defun)) (cond ((member keymap '('global 'local))