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)))
|
||||
|
||||
;; 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
|
||||
;; 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
|
||||
;; create one for C-i. Won't work in TTY frames, though. Doom's :os tty module
|
||||
;; has a workaround for that though.
|
||||
(pcase-dolist (`(,key ,fallback . ,events)
|
||||
'(([C-i] [?\C-i] tab kp-tab)
|
||||
([C-m] [?\C-m] return kp-return)))
|
||||
(define-key
|
||||
input-decode-map fallback
|
||||
(cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
||||
(and (display-graphic-p)
|
||||
(not (cl-loop for event in events
|
||||
if (cl-position event keys)
|
||||
return t))
|
||||
;; Use FALLBACK if nothing is bound to KEY, otherwise we've
|
||||
;; broken all pre-existing FALLBACK keybinds.
|
||||
(key-binding
|
||||
(vconcat (if (= 0 (length keys)) [] (cl-subseq keys 0 -1))
|
||||
key) nil t)))
|
||||
key fallback))))
|
||||
(defun doom-init-input-decode-map-h ()
|
||||
(pcase-dolist (`(,key ,fallback . ,events)
|
||||
'(([C-i] [?\C-i] tab kp-tab)
|
||||
([C-m] [?\C-m] return kp-return)))
|
||||
(define-key
|
||||
input-decode-map fallback
|
||||
(cmd! (if (when-let ((keys (this-single-command-raw-keys)))
|
||||
(and (display-graphic-p)
|
||||
(not (cl-loop for event in events
|
||||
if (cl-position event keys)
|
||||
return t))
|
||||
;; Use FALLBACK if nothing is bound to KEY, otherwise
|
||||
;; we've broken all pre-existing FALLBACK keybinds.
|
||||
(key-binding
|
||||
(vconcat (if (= 0 (length keys)) [] (cl-subseq keys 0 -1))
|
||||
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