fix: out-of-bounds error if this-single-command-raw-keys is empty
It seems there's an edge case in EXWM where input events may occur without keys to cause them (#8064), so these two keybind fixes need to be ready to receive an empty vector from `this-single-command-raw-keys`. Fix: #8064
This commit is contained in:
parent
d735c9be3d
commit
14189be77c
1 changed files with 23 additions and 28 deletions
|
@ -50,34 +50,29 @@ and Emacs states, and for non-evil users.")
|
||||||
(setq w32-lwindow-modifier 'super
|
(setq w32-lwindow-modifier 'super
|
||||||
w32-rwindow-modifier 'super)))
|
w32-rwindow-modifier 'super)))
|
||||||
|
|
||||||
;; HACK: Emacs can't distinguish C-i from TAB in either GUI or TTY frames. This
|
;; HACK: Emacs can't distinguish C-i from TAB, or C-m from RET, in either GUI or
|
||||||
;; is a byproduct of its history with the terminal, which can't distinguish
|
;; TTY frames. This is a byproduct of its history with the terminal, which
|
||||||
;; them either, however, Emacs has separate input events for many contentious
|
;; can't distinguish them either, however, Emacs has separate input events for
|
||||||
;; keys like TAB and RET (like [tab] and [return], aka "<tab>" and
|
;; many contentious keys like TAB and RET (like [tab] and [return], aka
|
||||||
;; "<return>"), which are only triggered in GUI frames, so here, I create one
|
;; "<tab>" and "<return>"), which are only triggered in GUI frames, so here, I
|
||||||
;; for C-i. Won't work in TTY frames, though. Doom's :os tty module has a
|
;; create one for C-i. Won't work in TTY frames, though. Doom's :os tty module
|
||||||
;; workaround for that though.
|
;; has a workaround for that though.
|
||||||
(define-key input-decode-map
|
(pcase-dolist (`(,key ,fallback . ,events)
|
||||||
[?\C-i] (cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
'(([C-i] [?\C-i] tab kp-tab)
|
||||||
(and (display-graphic-p)
|
([C-m] [?\C-m] return kp-return)))
|
||||||
(not (cl-position 'tab keys))
|
(define-key
|
||||||
(not (cl-position 'kp-tab keys))
|
input-decode-map fallback
|
||||||
;; Fall back if no <C-i> keybind can be found,
|
(cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
||||||
;; otherwise we've broken all pre-existing C-i
|
(and (display-graphic-p)
|
||||||
;; keybinds.
|
(not (cl-loop for event in events
|
||||||
(key-binding (vconcat (cl-subseq keys 0 -1) [C-i]) nil t)))
|
if (cl-position event keys)
|
||||||
[C-i] [?\C-i])))
|
return t))
|
||||||
|
;; Use FALLBACK if nothing is bound to KEY, otherwise we've
|
||||||
;; HACK: Same as C-i, but C-m is a little harder. There is no workaround for
|
;; broken all pre-existing FALLBACK keybinds.
|
||||||
;; this for the terminal.
|
(key-binding
|
||||||
(define-key input-decode-map
|
(vconcat (if (= 0 (length keys)) [] (cl-subseq keys 0 -1))
|
||||||
[?\C-m] (cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
key) nil t)))
|
||||||
(and (display-graphic-p)
|
key fallback))))
|
||||||
(not (cl-position 'return keys))
|
|
||||||
(not (cl-position 'kp-return keys))
|
|
||||||
;; Fall back if no <C-m> keybind can be found.
|
|
||||||
(key-binding (vconcat (cl-subseq keys 0 -1) [C-m]) nil t)))
|
|
||||||
[C-m] [?\C-m])))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue