Make exwm-mode buffers work with winner-mode

* exwm-input.el (exwm-input--noop): New placeholder command.
(exwm-input--on-pre-command, exwm-input--on-post-command): Ignore this
command.
(exwm-input--on-KeyPress-line-mode): Set `last-command' to make
winner-undo start over from the newest config; run
`post-command-hook' to make winner-mode save configs; run
`pre-command-hook' in case required by some other package.
This commit is contained in:
Chris Feng 2020-03-01 00:00:00 +00:00
parent 48db94f48b
commit ed0f63327d

View file

@ -649,6 +649,10 @@ Current buffer must be an `exwm-mode' buffer."
(lookup-key (current-local-map) (vector event)) (lookup-key (current-local-map) (vector event))
(gethash event exwm-input--simulation-keys))) (gethash event exwm-input--simulation-keys)))
(defun exwm-input--noop (&rest _args)
"A placeholder command."
(interactive))
(defun exwm-input--on-KeyPress-line-mode (key-press raw-data) (defun exwm-input--on-KeyPress-line-mode (key-press raw-data)
"Parse X KeyPress event to Emacs key event and then feed the command loop." "Parse X KeyPress event to Emacs key event and then feed the command loop."
(with-slots (detail state) key-press (with-slots (detail state) key-press
@ -678,10 +682,15 @@ Current buffer must be an `exwm-mode' buffer."
:destination (slot-value key-press 'event) :destination (slot-value key-press 'event)
:event-mask xcb:EventMask:NoEvent :event-mask xcb:EventMask:NoEvent
:event raw-data))) :event raw-data)))
(if defining-kbd-macro
(when event
;; Make Emacs aware of this event when defining keyboard macros. ;; Make Emacs aware of this event when defining keyboard macros.
(when (and defining-kbd-macro event) (set-transient-map `(keymap (t . ,#'exwm-input--noop)))
(set-transient-map '(keymap (t . (lambda () (interactive))))) (exwm-input--unread-event event))
(exwm-input--unread-event event))) ;; Fool some packages into thinking there is a change in the buffer.
(setq last-command #'exwm-input--noop)
(run-hooks 'pre-command-hook)
(run-hooks 'post-command-hook)))
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:AllowEvents (make-instance 'xcb:AllowEvents
:mode mode :mode mode
@ -1067,12 +1076,14 @@ One use is to access the keymap bound to KEYS (as prefix keys) in char-mode."
(defun exwm-input--on-pre-command () (defun exwm-input--on-pre-command ()
"Run in `pre-command-hook'." "Run in `pre-command-hook'."
(unless (memq this-command exwm-input-pre-post-command-blacklist) (unless (or (eq this-command #'exwm-input--noop)
(memq this-command exwm-input-pre-post-command-blacklist))
(setq exwm-input--during-command t))) (setq exwm-input--during-command t)))
(defun exwm-input--on-post-command () (defun exwm-input--on-post-command ()
"Run in `post-command-hook'." "Run in `post-command-hook'."
(setq exwm-input--during-command nil)) (unless (eq this-command #'exwm-input--noop)
(setq exwm-input--during-command nil)))
(defun exwm-input--on-minibuffer-setup () (defun exwm-input--on-minibuffer-setup ()
"Run in `minibuffer-setup-hook' to grab keyboard if necessary." "Run in `minibuffer-setup-hook' to grab keyboard if necessary."