emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/exwm dd96fff 1/2: Add extra keys for selecting workspac


From: Chris Feng
Subject: [elpa] externals/exwm dd96fff 1/2: Add extra keys for selecting workspace
Date: Sun, 17 Mar 2019 09:11:13 -0400 (EDT)

branch: externals/exwm
commit dd96fffb52a4e7e5b506b28881b518b0359375c4
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    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.
---
 exwm-workspace.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/exwm-workspace.el b/exwm-workspace.el
index 7832873..f6b8fba 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]