unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#65735: [PATCH] key-translate should use the 1st key of a key sequence
@ 2023-09-04 15:46 Shynur Xie
  2023-09-07  7:54 ` Robert Pluim
  0 siblings, 1 reply; 9+ messages in thread
From: Shynur Xie @ 2023-09-04 15:46 UTC (permalink / raw)
  To: 65735

[-- Attachment #1: Type: text/plain, Size: 104 bytes --]

To make 

    (key-translate "C-x" "<control-x>")
    ;; this is an example in elisp manual 

work.

[-- Attachment #2: 0001-key-translate-uses-the-1st-key-of-a-key-sequence.patch --]
[-- Type: application/octet-stream, Size: 1386 bytes --]

From 856bd7a0c696d0ff22e62d70688b287a8214dcda Mon Sep 17 00:00:00 2001
From: shynur <one.last.kiss@outlook.com>
Date: Mon, 4 Sep 2023 23:37:33 +0800
Subject: [PATCH] `key-translate' uses the 1st key of a key sequence

---
 lisp/keymap.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/keymap.el b/lisp/keymap.el
index 017b2d6..5a4021a 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -378,7 +378,7 @@ which is
 This function creates a `keyboard-translate-table' if necessary
 and then modifies one entry in it.
 
-Both KEY 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'."
   (declare (compiler-macro
             (lambda (form) (keymap--compile-check from to) form)))
   (keymap--check from)
@@ -386,7 +386,9 @@ Both KEY and TO should be specified by strings that satisfy `key-valid-p'."
   (or (char-table-p keyboard-translate-table)
       (setq keyboard-translate-table
 	    (make-char-table 'keyboard-translate-table nil)))
-  (aset keyboard-translate-table (key-parse from) (key-parse to)))
+  (aset keyboard-translate-table
+        (aref (key-parse from) 0)
+        (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.41.0.windows.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-18  9:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04 15:46 bug#65735: [PATCH] key-translate should use the 1st key of a key sequence Shynur Xie
2023-09-07  7:54 ` Robert Pluim
2023-09-07  8:15   ` Eli Zaretskii
2023-09-07 11:57     ` Robert Pluim
2023-09-07 13:09       ` Eli Zaretskii
2023-09-07 14:01         ` Stefan Kangas
2023-09-18  9:49           ` Robert Pluim
2023-09-07 13:42       ` Shynur Xie
2023-09-07 13:49         ` Robert Pluim

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).