GNU bug report logs -
#70139
29.3.50; key-translate does not support all keyboard-translate usages
Previous Next
Reported by: Robert Pluim <rpluim <at> gmail.com>
Date: Tue, 2 Apr 2024 09:52:04 UTC
Severity: normal
Found in version 29.3.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
This patch enhances the key-translate function to allow removing
keyboard translations by passing nil as the second argument (TO).
If TO is nil, any existing translation for the FROM key will be removed.
The compiler macro is updated to only check TO when it is non-nil.
This change makes key-translate more consistent with the behavior of
keyboard-translate, providing a way to remove translations without
having to specify the same key for both FROM and TO.
The documentation string is updated to reflect the new behavior.
---
lisp/keymap.el | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lisp/keymap.el b/lisp/keymap.el
index b2b475c7d71..1481f1fe72b 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -382,17 +382,19 @@ key-translate
This function creates a `keyboard-translate-table' if necessary
and then modifies one entry in it.
-Both FROM and TO should be specified by strings that satisfy `key-valid-p'."
+Both FROM and TO should be specified by strings that satisfy `key-valid-p'.
+If TO is nil, remove any existing translation for FROM."
(declare (compiler-macro
- (lambda (form) (keymap--compile-check from to) form)))
+ (lambda (form) (keymap--compile-check from (and to to)) form)))
(keymap--check from)
- (keymap--check to)
+ (when to
+ (keymap--check to))
(or (char-table-p keyboard-translate-table)
(setq keyboard-translate-table
(make-char-table 'keyboard-translate-table nil)))
(aset keyboard-translate-table
(aref (key-parse from) 0)
- (aref (key-parse to) 0)))
+ (and to (aref (key-parse to) 0))))
(defun keymap-lookup (keymap key &optional accept-default no-remap position)
"Return the binding for command KEY in KEYMAP.
--
2.34.1
This bug report was last modified 1 year and 16 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.