mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-27 13:07:59 +01:00
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:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'kmacro)
|
||||||
|
|
||||||
(require 'xcb)
|
(require 'xcb)
|
||||||
(require 'xcb-icccm)
|
(require 'xcb-icccm)
|
||||||
(require 'xcb-ewmh)
|
(require 'xcb-ewmh)
|
||||||
|
@ -78,6 +80,12 @@
|
||||||
(logior xcb:EventMask:StructureNotify xcb:EventMask:PropertyChange))
|
(logior xcb:EventMask:StructureNotify xcb:EventMask:PropertyChange))
|
||||||
"Event mask set on all managed windows.")
|
"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"
|
(declare-function exwm-input--on-KeyPress-line-mode "exwm-input.el"
|
||||||
(key-press raw-data))
|
(key-press raw-data))
|
||||||
|
|
||||||
|
@ -140,6 +148,26 @@
|
||||||
map)
|
map)
|
||||||
"Keymap for `exwm-mode'.")
|
"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
|
;; 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.
|
;; detailed as possible, even some entries do not make much sense here.
|
||||||
;; Also, inactive entries should be disabled rather than hidden.
|
;; Also, inactive entries should be disabled rather than hidden.
|
||||||
|
@ -226,6 +254,9 @@
|
||||||
;; Kill buffer -> close window
|
;; Kill buffer -> close window
|
||||||
(add-hook 'kill-buffer-query-functions
|
(add-hook 'kill-buffer-query-functions
|
||||||
#'exwm-manage--kill-buffer-query-function nil t)
|
#'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
|
(setq buffer-read-only t
|
||||||
left-margin-width nil
|
left-margin-width nil
|
||||||
right-margin-width nil
|
right-margin-width nil
|
||||||
|
|
|
@ -454,7 +454,11 @@ This value should always be overwritten.")
|
||||||
:propagate 0
|
:propagate 0
|
||||||
: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)))
|
||||||
|
;; 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
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:AllowEvents
|
(make-instance 'xcb:AllowEvents
|
||||||
:mode mode
|
:mode mode
|
||||||
|
|
Loading…
Reference in a new issue