mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-30 14:38:00 +01:00
Add extra keys for selecting workspace
* exwm-workspace.el (exwm-workspace--switch-map) (exwm-workspace--init): Avoid initializing the keymap when loading. (exwm-workspace--init-switch-map): Initialize `exwm-workspace--switch-map' and also add extra keybindings when `exwm-workspace-index-map' has been customized.
This commit is contained in:
parent
b12c67de2e
commit
dd96fffb52
1 changed files with 17 additions and 3 deletions
|
@ -157,7 +157,10 @@ NIL if FRAME is not a workspace"
|
||||||
"Return non-nil if FRAME is an emacsclient frame."
|
"Return non-nil if FRAME is an emacsclient frame."
|
||||||
(frame-parameter frame 'client))
|
(frame-parameter frame 'client))
|
||||||
|
|
||||||
(defvar exwm-workspace--switch-map
|
(defvar exwm-workspace--switch-map nil
|
||||||
|
"Keymap used for interactively selecting workspace.")
|
||||||
|
|
||||||
|
(defun exwm-workspace--init-switch-map ()
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(define-key map [t] (lambda () (interactive)))
|
(define-key map [t] (lambda () (interactive)))
|
||||||
(define-key map "+" #'exwm-workspace--prompt-add)
|
(define-key map "+" #'exwm-workspace--prompt-add)
|
||||||
|
@ -165,6 +168,17 @@ NIL if FRAME is not a workspace"
|
||||||
(dotimes (i 10)
|
(dotimes (i 10)
|
||||||
(define-key map (int-to-string i)
|
(define-key map (int-to-string i)
|
||||||
#'exwm-workspace--switch-map-nth-prefix))
|
#'exwm-workspace--switch-map-nth-prefix))
|
||||||
|
(unless (eq exwm-workspace-index-map #'number-to-string)
|
||||||
|
;; Add extra (and possibly override) keys for selecting workspace.
|
||||||
|
(dotimes (i 10)
|
||||||
|
(let ((key (funcall exwm-workspace-index-map i)))
|
||||||
|
(when (and (stringp key)
|
||||||
|
(= (length key) 1)
|
||||||
|
(<= 0 (elt key 0) 127))
|
||||||
|
(define-key map key
|
||||||
|
`(lambda ()
|
||||||
|
(interactive)
|
||||||
|
(exwm-workspace--switch-map-select-nth ,i)))))))
|
||||||
(define-key map "\C-a" (lambda () (interactive) (goto-history-element 1)))
|
(define-key map "\C-a" (lambda () (interactive) (goto-history-element 1)))
|
||||||
(define-key map "\C-e" (lambda ()
|
(define-key map "\C-e" (lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -180,8 +194,7 @@ NIL if FRAME is not a workspace"
|
||||||
;; Alternative keys
|
;; Alternative keys
|
||||||
(define-key map [right] #'previous-history-element)
|
(define-key map [right] #'previous-history-element)
|
||||||
(define-key map [left] #'next-history-element)
|
(define-key map [left] #'next-history-element)
|
||||||
map)
|
(setq exwm-workspace--switch-map map)))
|
||||||
"Keymap used for interactively switch workspace.")
|
|
||||||
|
|
||||||
(defun exwm-workspace--workspace-from-frame-or-index (frame-or-index)
|
(defun exwm-workspace--workspace-from-frame-or-index (frame-or-index)
|
||||||
"Retrieve the workspace frame from FRAME-OR-INDEX."
|
"Retrieve the workspace frame from FRAME-OR-INDEX."
|
||||||
|
@ -1557,6 +1570,7 @@ applied to all subsequently created X frames."
|
||||||
(defun exwm-workspace--init ()
|
(defun exwm-workspace--init ()
|
||||||
"Initialize workspace module."
|
"Initialize workspace module."
|
||||||
(exwm--log)
|
(exwm--log)
|
||||||
|
(exwm-workspace--init-switch-map)
|
||||||
;; Prevent unexpected exit
|
;; Prevent unexpected exit
|
||||||
(setq exwm-workspace--fullscreen-frame-count 0)
|
(setq exwm-workspace--fullscreen-frame-count 0)
|
||||||
(exwm-workspace--modify-all-x-frames-parameters
|
(exwm-workspace--modify-all-x-frames-parameters
|
||||||
|
|
Loading…
Reference in a new issue