[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/exwm d0797d0 13/19: Remove `exwm-worspace-number'
From: |
Chris Feng |
Subject: |
[elpa] externals/exwm d0797d0 13/19: Remove `exwm-worspace-number' |
Date: |
Tue, 19 Jul 2016 03:07:08 +0000 (UTC) |
branch: externals/exwm
commit d0797d03ded13aff09211ea77c6b37cccaf6ff12
Author: Adrián Medraño Calvo <address@hidden>
Commit: Adrián Medraño Calvo <address@hidden>
Remove `exwm-worspace-number'
No longer fill initial workspace list, nor limit the number of
workspaces to `exwm-worspace-number'.
Users are free to create as many as they like by hitting 'C-x 5 2' or
running `make-frame'.
The initial workspace list can be set up by creating frames in a
configuration file. For example, to start up with 4 workspaces:
(dolist (i 3)
(make-frame))
The interactive workspace switcher is improved to support selecting
workspaces with a many-digits position.
* exwm-workspace.el (exwm-workspace-number): Remove variable, as
we no longer have a fixed number of workspaces.
(exwm-workspace--switch-map)
(exwm-workspace--switch-map-nth-prefix)
(exwm-workspace--switch-map-select-nth): Improve support for
selecting workspaces with multiple-digit positions (e.g. workspace
number 12).
(exwm-workspace--add-frame-as-workspace, exwm-workspace--init):
Remove limit on number of workspaces.
(exwm-workspace--init): Stop creating workspaces at startup.
* exwm-config.el (exwm-config-default): Bind keys to namespaces
0-9 in the default configuration.
---
exwm-config.el | 2 +-
exwm-workspace.el | 99 ++++++++++++++++++++++++++++++++++-------------------
2 files changed, 64 insertions(+), 37 deletions(-)
diff --git a/exwm-config.el b/exwm-config.el
index d6e10f2..e1e5010 100644
--- a/exwm-config.el
+++ b/exwm-config.el
@@ -39,7 +39,7 @@
;; 's-w': Switch workspace
(exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
;; 's-N': Switch to certain workspace
- (dotimes (i exwm-workspace-number)
+ (dotimes (i 10)
(exwm-input-set-key (kbd (format "s-%d" i))
`(lambda () (interactive) (exwm-workspace-switch ,i))))
;; 's-&': Launch application
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 2a11756..75fcc96 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -27,7 +27,6 @@
(require 'exwm-core)
-(defvar exwm-workspace-number 4 "Number of workspaces (1 ~ 10).")
(defvar exwm-workspace--list nil "List of all workspaces (Emacs frames).")
(defvar exwm-workspace--current nil "Current active workspace.")
(defvar exwm-workspace-current-index 0 "Index of current active workspace.")
@@ -63,12 +62,7 @@ NIL if FRAME is not a workspace"
(let ((map (make-sparse-keymap)))
(define-key map [t] (lambda () (interactive)))
(dotimes (i 10)
- (define-key map (int-to-string i)
- `(lambda ()
- (interactive)
- (when (< ,i (exwm-workspace--count))
- (goto-history-element ,(1+ i))
- (exit-minibuffer)))))
+ (define-key map (int-to-string i)
#'exwm-workspace--switch-map-nth-prefix))
(define-key map "\C-a" (lambda () (interactive) (goto-history-element 1)))
(define-key map "\C-e" (lambda ()
(interactive)
@@ -318,6 +312,48 @@ Value nil means to use the default position which is fixed
at bottom, while
:stack-mode xcb:StackMode:Above))
(set-frame-width exwm-workspace--minibuffer width nil t)))
+(defun exwm-workspace--switch-map-nth-prefix (&optional prefix-digits)
+ "Allow selecting a workspace by number.
+
+PREFIX-DIGITS is a list of the digits introduced so far."
+ (interactive)
+ (let* ((ev (this-command-keys-vector))
+ (off (1- (length ev)))
+ (k (elt ev off))
+ ;; 0 is ASCII 48.
+ (d (- k 48))
+ ;; Convert prefix-digits to number. For example, '(2 1) to 120.
+ (o 1)
+ (pn (apply #'+ (mapcar (lambda (x)
+ (setq o (* 10 o))
+ (* o x))
+ prefix-digits)))
+ (n (+ pn d))
+ (num-workspaces (exwm-workspace--count)))
+ (if (= (length prefix-digits) ; Go ahead if there are enough
+ (floor (log num-workspaces 10))) ; digits to select any workspace.
+ (exwm-workspace--switch-map-select-nth n)
+ (set-transient-map
+ (let ((map (make-sparse-keymap))
+ (cmd `(lambda ()
+ (interactive)
+ (exwm-workspace--switch-map-nth-prefix ',(cons d
prefix-digits))
+ )))
+ (dotimes (i 10)
+ (define-key map (int-to-string i) cmd))
+ ;; Accept
+ (define-key map [return]
+ `(lambda ()
+ (interactive)
+ (exwm-workspace--switch-map-select-nth ,n)))
+ map)))))
+
+(defun exwm-workspace--switch-map-select-nth (n)
+ "Select Nth workspace."
+ (interactive)
+ (goto-history-element (1+ n))
+ (exit-minibuffer))
+
(defvar exwm-workspace-switch-hook nil
"Normal hook run after switching workspace.")
@@ -854,9 +890,6 @@ before it."
(defun exwm-workspace--add-frame-as-workspace (frame)
"Configure frame FRAME to be treated as a workspace."
(cond
- ((>= (exwm-workspace--count) exwm-workspace-number)
- (delete-frame frame)
- (user-error "[EXWM] Too many workspaces: maximum is %d"
exwm-workspace-number))
((exwm-workspace--workspace-p frame)
(exwm--log "Frame `%s' is already a workspace" frame))
((not (display-graphic-p frame))
@@ -1010,31 +1043,23 @@ applied to all subsequently created X frames."
(defun exwm-workspace--init ()
"Initialize workspace module."
- (cl-assert (and (< 0 exwm-workspace-number) (>= 10 exwm-workspace-number)))
;; Prevent unexpected exit
(setq confirm-kill-emacs #'exwm-workspace--confirm-kill-emacs)
(let ((initial-workspaces (frame-list)))
(if (not (exwm-workspace--minibuffer-own-frame-p))
;; Initialize workspaces with minibuffers.
- (progn
- (when (< 1 (exwm-workspace--count))
- ;; Exclude the initial frame.
- (dolist (i initial-workspaces)
- (unless (frame-parameter i 'window-id)
- (setq initial-workspaces (delq i initial-workspaces))))
- (cl-assert (= 1 (length initial-workspaces)))
- (setq exwm-workspace--client
- (frame-parameter (car exwm-workspace--list) 'client))
- (let ((f (car initial-workspaces)))
- ;; Remove the possible internal border.
- (set-frame-parameter f 'internal-border-width 0)
- ;; Prevent user from deleting this frame by accident.
- (set-frame-parameter f 'client nil)))
- ;; Create remaining frames.
- (dotimes (_ (1- exwm-workspace-number))
- (nconc initial-workspaces
- (list (make-frame '((window-system . x)
- (internal-border-width . 0)))))))
+ (when (< 1 (length initial-workspaces))
+ ;; Exclude the initial frame.
+ (dolist (i initial-workspaces)
+ (unless (frame-parameter i 'window-id)
+ (setq initial-workspaces (delq i initial-workspaces))))
+ (setq exwm-workspace--client
+ (frame-parameter (car exwm-workspace--list) 'client))
+ (let ((f (car initial-workspaces)))
+ ;; Remove the possible internal border.
+ (set-frame-parameter f 'internal-border-width 0)
+ ;; Prevent user from deleting the first frame by accident.
+ (set-frame-parameter f 'client nil)))
;; Initialize workspaces without minibuffers.
(setq exwm-workspace--minibuffer
(make-frame '((window-system . x) (minibuffer . only)
@@ -1092,12 +1117,14 @@ applied to all subsequently created X frames."
(setq exwm-workspace--timer
(run-with-idle-timer 0 t #'exwm-workspace--on-echo-area-dirty))
(add-hook 'echo-area-clear-hook #'exwm-workspace--on-echo-area-clear)
- ;; Create workspace frames.
- (dotimes (_ exwm-workspace-number)
- (push (make-frame `((window-system . x)
- (internal-border-width . 0)
- (client . nil)))
- exwm-workspace--list))
+ ;; Recreate frames with the external minibuffer set.
+ (setq initial-workspaces
+ (mapcar
+ (lambda (_)
+ (make-frame `((window-system . x)
+ (internal-border-width . 0)
+ (client . nil))))
+ initial-workspaces))
;; The default behavior of `display-buffer' (indirectly called by
;; `minibuffer-completion-help') is not correct here.
(cl-pushnew '(exwm-workspace--display-buffer) display-buffer-alist
- [elpa] externals/exwm updated (c22f356 -> b409d87), Chris Feng, 2016/07/18
- [elpa] externals/exwm ed6a18a 04/19: Add `exwm-workspace--position' helper, Chris Feng, 2016/07/18
- [elpa] externals/exwm f4b8cc4 11/19: Support moving workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm 9018545 06/19: New function exwm-workspace--workspace-p, Chris Feng, 2016/07/18
- [elpa] externals/exwm cd1372e 03/19: Apply minibuffer in own frame configuration to created frames, Chris Feng, 2016/07/18
- [elpa] externals/exwm d0797d0 13/19: Remove `exwm-worspace-number',
Chris Feng <=
- [elpa] externals/exwm 18fc95d 01/19: Minor cleanup, Chris Feng, 2016/07/18
- [elpa] externals/exwm 983fd46 02/19: Add missing declarations, Chris Feng, 2016/07/18
- [elpa] externals/exwm 35e1655 07/19: Move defvars to the top, Chris Feng, 2016/07/18
- [elpa] externals/exwm e491118 10/19: Support swapping workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm 8e2da00 05/19: Add helper for counting number of workspaces, Chris Feng, 2016/07/18
- [elpa] externals/exwm 2de2d42 09/19: Factor out prompt for workspace, Chris Feng, 2016/07/18
- [elpa] externals/exwm b51f3e6 18/19: Mention dynamic workspace in various places, Chris Feng, 2016/07/18
- [elpa] externals/exwm 2ebeec1 17/19: Adapt dynamic workspace for RandR module, Chris Feng, 2016/07/18
- [elpa] externals/exwm 4c9afc2 16/19: Adapt dynamic workspace for floating module, Chris Feng, 2016/07/18
- [elpa] externals/exwm 622618a 15/19: Improve the handling of workspaces, Chris Feng, 2016/07/18