From 585b5e852673866980e964e9aae17e82b32a37cb Mon Sep 17 00:00:00 2001 From: Le Wang Date: Sat, 21 Feb 2026 06:10:49 -0500 Subject: [PATCH 1/3] Register keys with key-chord's tracking optimization key-chord has an optimization where the input method skips chord detection for keys not registered in any chord. key-seq-define was not calling key-chord-register-keys, so defined sequences could be silently ignored. Call register/unregister to keep the two packages in sync. --- key-seq.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/key-seq.el b/key-seq.el index 020902b..27b031a 100644 --- a/key-seq.el +++ b/key-seq.el @@ -94,12 +94,20 @@ that corresponds to ascii codes in the range 32 to 126 can be used. If COMMAND is nil, the key-chord is removed." (if (/= 2 (length keys)) (error "Key-chord keys must have two elements")) - ;; Exotic chars in a string are >255 but define-key wants 128..255 for those - (let ((key1 (logand 255 (aref keys 0))) - (key2 (logand 255 (aref keys 1)))) + (let ((key1 (aref keys 0)) + (key2 (aref keys 1))) + (unless (and (integerp key1) (< key1 256) + (integerp key2) (< key2 256)) + (error "Key-seq keys must both be bytes (characters with codes < 256)")) (if (eq key1 key2) (define-key keymap (vector 'key-chord key1 key2) command) - (define-key keymap (vector 'key-chord key1 key2) command)))) + (define-key keymap (vector 'key-chord key1 key2) command)) + ;; Register keys with key-chord's tracking optimization so the + ;; input method doesn't skip chord detection for these keys. + (when (fboundp 'key-chord-register-keys) + (if command + (key-chord-register-keys key1 key2) + (key-chord-unregister-keys key1 key2))))) (defun key-seq-unset-global (keys) "Remove global key sequence of the two keys in KEYS." From bcd49446d2b220b5b9f06102602cb517570895bd Mon Sep 17 00:00:00 2001 From: Le Wang Date: Sat, 21 Feb 2026 06:44:22 -0500 Subject: [PATCH 2/3] Enable lexical-binding --- key-seq.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/key-seq.el b/key-seq.el index 27b031a..39adbf3 100644 --- a/key-seq.el +++ b/key-seq.el @@ -1,4 +1,4 @@ -;;; key-seq.el --- map pairs of sequentially pressed keys to commands +;;; key-seq.el --- map pairs of sequentially pressed keys to commands -*- lexical-binding: t; -*- ;; Copyright (C) 2015 Vyacheslav Levit ;; Copyright (C) 2003,2005,2008,2012 David Andersson From 3b39d74e54e3d01cf3d0560ea76c2b0594378c3d Mon Sep 17 00:00:00 2001 From: Le Wang Date: Sat, 21 Feb 2026 06:53:15 -0500 Subject: [PATCH 3/3] Add declare-function for key-chord functions Silence native-compiler warnings for key-chord-register-keys and key-chord-unregister-keys which are called conditionally via fboundp. --- key-seq.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/key-seq.el b/key-seq.el index 39adbf3..7af8116 100644 --- a/key-seq.el +++ b/key-seq.el @@ -62,6 +62,9 @@ ;;; Code: +(declare-function key-chord-register-keys "key-chord" (key1 key2)) +(declare-function key-chord-unregister-keys "key-chord" (key1 key2)) + ;;;###autoload (defun key-seq-define-global (keys command) "Define a key sequence of the two keys in KEYS starting a COMMAND.