mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
fix: TAB & RET keybinds in daemon sessions
`input-decode-map`s bindings are terminal-local and are memoized at an
indeterminable time by `read-key-sequence`, rendering that
`display-graphic-p` check stale by the first client frame and these
TAB/RET fixes unavailable to daemon users.
Amend: 538ddf5e66
Fix: #8269
Close: #8303
This commit is contained in:
committed by
Henrik Lissner
parent
960b537cf6
commit
0e5768064c
@ -51,28 +51,35 @@ and Emacs states, and for non-evil users.")
|
|||||||
w32-rwindow-modifier 'super)))
|
w32-rwindow-modifier 'super)))
|
||||||
|
|
||||||
;; HACK: Emacs can't distinguish C-i from TAB, or C-m from RET, in either GUI or
|
;; HACK: Emacs can't distinguish C-i from TAB, or C-m from RET, in either GUI or
|
||||||
;; TTY frames. This is a byproduct of its history with the terminal, which
|
;; TTY frames. This is a byproduct of its history with the terminal, which
|
||||||
;; can't distinguish them either, however, Emacs has separate input events for
|
;; can't distinguish them either, however, Emacs has separate input events for
|
||||||
;; many contentious keys like TAB and RET (like [tab] and [return], aka
|
;; many contentious keys like TAB and RET (like [tab] and [return], aka
|
||||||
;; "<tab>" and "<return>"), which are only triggered in GUI frames, so here, I
|
;; "<tab>" and "<return>"), which are only triggered in GUI frames, so here, I
|
||||||
;; create one for C-i. Won't work in TTY frames, though. Doom's :os tty module
|
;; create one for C-i. Won't work in TTY frames, though. Doom's :os tty module
|
||||||
;; has a workaround for that though.
|
;; has a workaround for that though.
|
||||||
(pcase-dolist (`(,key ,fallback . ,events)
|
(defun doom-init-input-decode-map-h ()
|
||||||
'(([C-i] [?\C-i] tab kp-tab)
|
(pcase-dolist (`(,key ,fallback . ,events)
|
||||||
([C-m] [?\C-m] return kp-return)))
|
'(([C-i] [?\C-i] tab kp-tab)
|
||||||
(define-key
|
([C-m] [?\C-m] return kp-return)))
|
||||||
input-decode-map fallback
|
(define-key
|
||||||
(cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
input-decode-map fallback
|
||||||
(and (display-graphic-p)
|
(cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
||||||
(not (cl-loop for event in events
|
(and (display-graphic-p)
|
||||||
if (cl-position event keys)
|
(not (cl-loop for event in events
|
||||||
return t))
|
if (cl-position event keys)
|
||||||
;; Use FALLBACK if nothing is bound to KEY, otherwise we've
|
return t))
|
||||||
;; broken all pre-existing FALLBACK keybinds.
|
;; Use FALLBACK if nothing is bound to KEY, otherwise
|
||||||
(key-binding
|
;; we've broken all pre-existing FALLBACK keybinds.
|
||||||
(vconcat (if (= 0 (length keys)) [] (cl-subseq keys 0 -1))
|
(key-binding
|
||||||
key) nil t)))
|
(vconcat (if (= 0 (length keys)) [] (cl-subseq keys 0 -1))
|
||||||
key fallback))))
|
key) nil t)))
|
||||||
|
key fallback)))))
|
||||||
|
|
||||||
|
;; `input-decode-map' bindings are resolved on first invokation, and are
|
||||||
|
;; frame-local, so they must be rebound on every new frame.
|
||||||
|
(if (daemonp)
|
||||||
|
(add-hook 'server-after-make-frame-hook #'doom-init-input-decode-map-h)
|
||||||
|
(doom-init-input-decode-map-h))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user