diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2016-09-22T11·10+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2016-09-22T11·10+0800 |
commit | f96f565d548521a87e0f3a23bfab7f5b836e4640 (patch) | |
tree | 5b9bf6a9d37f226ff77a2468427d9fd52f461418 /exwm-core.el | |
parent | 43af6bb6a295fc843bd8b1f890cca1c246293e90 (diff) |
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.
Diffstat (limited to 'exwm-core.el')
-rw-r--r-- | exwm-core.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/exwm-core.el b/exwm-core.el index e65ad5169093..8f5299f16b1f 100644 --- a/exwm-core.el +++ b/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 |