Add support for keyboard macro
* exwm-core.el (exwm--kmacro-map): New keymap used when executing keyboard macros. (exwm-mode): Use `exwm--kmacro-map' to override the default keymap. * exwm-input.el (exwm-input--on-KeyPress-line-mode): Send extra key events when defining keyboard macros.
This commit is contained in:
parent
43af6bb6a2
commit
f96f565d54
2 changed files with 36 additions and 1 deletions
31
exwm-core.el
31
exwm-core.el
|
@ -26,6 +26,8 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'kmacro)
|
||||
|
||||
(require 'xcb)
|
||||
(require 'xcb-icccm)
|
||||
(require 'xcb-ewmh)
|
||||
|
@ -78,6 +80,12 @@
|
|||
(logior xcb:EventMask:StructureNotify xcb:EventMask:PropertyChange))
|
||||
"Event mask set on all managed windows.")
|
||||
|
||||
(defvar exwm-input--during-key-sequence)
|
||||
(defvar exwm-input--global-prefix-keys)
|
||||
(defvar exwm-input-prefix-keys)
|
||||
(defvar exwm-input--simulation-prefix-keys)
|
||||
|
||||
(declare-function exwm-input--fake-key "exwm-input.el" (event))
|
||||
(declare-function exwm-input--on-KeyPress-line-mode "exwm-input.el"
|
||||
(key-press raw-data))
|
||||
|
||||
|
@ -140,6 +148,26 @@
|
|||
map)
|
||||
"Keymap for `exwm-mode'.")
|
||||
|
||||
(defvar exwm--kmacro-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map [t]
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(cond
|
||||
((or exwm-input--during-key-sequence
|
||||
;; Do not test `exwm-input--during-command'.
|
||||
(active-minibuffer-window)
|
||||
(memq last-input-event exwm-input--global-prefix-keys)
|
||||
(memq last-input-event exwm-input-prefix-keys)
|
||||
(memq last-input-event exwm-input--simulation-prefix-keys))
|
||||
(set-transient-map (make-composed-keymap (list exwm-mode-map
|
||||
global-map)))
|
||||
(push last-input-event unread-command-events))
|
||||
(t
|
||||
(exwm-input--fake-key last-input-event)))))
|
||||
map)
|
||||
"Keymap used when executing keyboard macros.")
|
||||
|
||||
;; This menu mainly acts as an reminder for users. Thus it should be as
|
||||
;; detailed as possible, even some entries do not make much sense here.
|
||||
;; Also, inactive entries should be disabled rather than hidden.
|
||||
|
@ -226,6 +254,9 @@
|
|||
;; Kill buffer -> close window
|
||||
(add-hook 'kill-buffer-query-functions
|
||||
#'exwm-manage--kill-buffer-query-function nil t)
|
||||
;; Redirect events when executing keyboard macros.
|
||||
(push `(executing-kbd-macro . ,exwm--kmacro-map)
|
||||
minor-mode-overriding-map-alist)
|
||||
(setq buffer-read-only t
|
||||
left-margin-width nil
|
||||
right-margin-width nil
|
||||
|
|
|
@ -454,7 +454,11 @@ This value should always be overwritten.")
|
|||
:propagate 0
|
||||
:destination (slot-value key-press 'event)
|
||||
:event-mask xcb:EventMask:NoEvent
|
||||
:event raw-data))))
|
||||
:event raw-data)))
|
||||
;; Make Emacs aware of this event when defining keyboard macros.
|
||||
(when (and defining-kbd-macro event)
|
||||
(set-transient-map '(keymap (t . (lambda () (interactive)))))
|
||||
(exwm-input--unread-event event)))
|
||||
(xcb:+request exwm--connection
|
||||
(make-instance 'xcb:AllowEvents
|
||||
:mode mode
|
||||
|
|
Loading…
Reference in a new issue