mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-27 06:48: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."
|
||||
(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)))
|
||||
(define-key map [t] (lambda () (interactive)))
|
||||
(define-key map "+" #'exwm-workspace--prompt-add)
|
||||
|
@ -165,6 +168,17 @@ NIL if FRAME is not a workspace"
|
|||
(dotimes (i 10)
|
||||
(define-key map (int-to-string i)
|
||||
#'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-e" (lambda ()
|
||||
(interactive)
|
||||
|
@ -180,8 +194,7 @@ NIL if FRAME is not a workspace"
|
|||
;; Alternative keys
|
||||
(define-key map [right] #'previous-history-element)
|
||||
(define-key map [left] #'next-history-element)
|
||||
map)
|
||||
"Keymap used for interactively switch workspace.")
|
||||
(setq exwm-workspace--switch-map map)))
|
||||
|
||||
(defun exwm-workspace--workspace-from-frame-or-index (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 ()
|
||||
"Initialize workspace module."
|
||||
(exwm--log)
|
||||
(exwm-workspace--init-switch-map)
|
||||
;; Prevent unexpected exit
|
||||
(setq exwm-workspace--fullscreen-frame-count 0)
|
||||
(exwm-workspace--modify-all-x-frames-parameters
|
||||
|
|
Loading…
Reference in a new issue