[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/window-commander c2c579a3c9 061/170: Construct multi-ch
From: |
ELPA Syncer |
Subject: |
[elpa] externals/window-commander c2c579a3c9 061/170: Construct multi-character IDs without pre-computing all possible IDs |
Date: |
Wed, 28 Jun 2023 19:00:26 -0400 (EDT) |
branch: externals/window-commander
commit c2c579a3c9fd27dde0e1223a328d682e67694ed4
Author: Daniel Semyonov <cmstr@dsemy.com>
Commit: Daniel Semyonov <cmstr@dsemy.com>
Construct multi-character IDs without pre-computing all possible IDs
* swsw.el (swsw--get-possible-ids): Removed.
(swsw--id-counter): New variable used to determine the next ID.
(swsw--id-next-id): New function which returns the next available ID.
(swsw-update-window): Call 'swsw--next-id' instead of getting the
next ID from 'swsw-ids'.
(swsw-update): Remove construction of a list of all possible IDs.
Add step to reset 'swsw--id-counter'.
---
swsw.el | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/swsw.el b/swsw.el
index 1bfd882ecc..2429aacdbc 100644
--- a/swsw.el
+++ b/swsw.el
@@ -129,16 +129,6 @@ If set to ‘lighter’, use the mode line lighter of
‘swsw-mode’."
(selected-frame)
swsw-scope))
-(defun swsw--get-possible-ids (&rest char-lists)
- "Return the Cartesian product of all CHAR-LISTS."
- (if char-lists
- (mapcan (lambda (inner)
- (mapcar (lambda (outer)
- (cons outer inner))
- (car char-lists)))
- (apply #'swsw--get-possible-ids (cdr char-lists)))
- (list nil)))
-
(defun swsw--get-id-length ()
"Return the current length of a window ID."
(let ((windows (length (window-list-1 nil nil (swsw--get-scope)))))
@@ -149,11 +139,29 @@ If set to ‘lighter’, use the mode line lighter of
‘swsw-mode’."
windows
(length swsw-id-chars))))))
+(defvar swsw--id-counter nil
+ "Counter which determines the next possible ID.")
+
+(defun swsw--next-id ()
+ "Get the next available ID."
+ (let ((len (length swsw-id-chars)) (adv-flag t) id)
+ (setq swsw--id-counter
+ (mapcar (lambda (elt)
+ (push (nth elt swsw-id-chars) id)
+ ;; Advance ‘swsw--id-counter’.
+ (when adv-flag
+ (if (= len (setq elt (1+ elt)))
+ (setq elt 0)
+ (setq adv-flag nil)))
+ elt)
+ swsw--id-counter))
+ id))
+
(defun swsw-update-window (window)
"Update information for WINDOW."
(let ((id (if (window-minibuffer-p window)
swsw-minibuffer-id
- (pop swsw-ids))))
+ (swsw--next-id))))
(when id
(push (cons id window) swsw-window-list)
(set-window-parameter window 'swsw-id id))))
@@ -161,12 +169,11 @@ If set to ‘lighter’, use the mode line lighter of
‘swsw-mode’."
(defun swsw-update (&optional _frame)
"Update information for all windows."
(setq swsw-window-list nil
- ;; Build a list of all possible IDs for the current length.
- swsw-ids (let ((acc 0) (len (swsw--get-id-length)) char-lists)
- (while (< acc len)
- (push swsw-id-chars char-lists)
- (setq acc (1+ acc)))
- (apply #'swsw--get-possible-ids char-lists)))
+ swsw--id-counter nil)
+ (let ((acc 0) (len (swsw--get-id-length)))
+ (while (< acc len)
+ (push 0 swsw--id-counter)
+ (setq acc (1+ acc))))
(walk-windows #'swsw-update-window nil (swsw--get-scope)))
(defun swsw-format-id (window)
- [elpa] externals/window-commander 08b56d124c 015/170: Add support for multi-character IDs, (continued)
- [elpa] externals/window-commander 08b56d124c 015/170: Add support for multi-character IDs, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 96809a6cae 019/170: Add the ability to change the way window IDs are displayed, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 4c84ca310f 016/170: ; Update README to reflect recent changes, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 48db8fe39b 021/170: Add a reference implementation for a conditional display function, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 8a8be23f1b 050/170: ; Include license information in created package archives, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander ec011dc3b9 053/170: ; Fix inconsistency in URL between swsw.el and swsw-pkg.el, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 0a3edee2e5 055/170: ; Bump version to 1.1.1 and update NEWS file, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 0b67d7bc00 056/170: * swsw.el (swsw-display-function): Define early only when byte-compiling, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 5446df0f3e 059/170: * swsw.el (swsw--get-id-length): Fix the calculation of the ID length, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 095091cf33 057/170: Handle cases where there are less than three tracked windows better, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander c2c579a3c9 061/170: Construct multi-character IDs without pre-computing all possible IDs,
ELPA Syncer <=
- [elpa] externals/window-commander 7d82ffeef4 076/170: ; Small modifications to the NEWS file, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander d7fe615c3f 049/170: ; Fix inconsistency between requirements in swsw.el and swsw-pkg.el, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander cacbe44c08 058/170: ; Remove unnecessary ':group' keywords from 'defcustom' calls, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 73a241cf38 064/170: Ensure 'swsw-id-chars' is set correctly when customized, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander f66c043abc 067/170: Only call 'swsw-update' automatically when it's bound, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 53321ab4f2 069/170: ; Correct swsw-select's docstring, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander dbe46d5b86 070/170: * swsw.el (swsw-select): Don't select the next window for non-existent IDs, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 03747300a3 082/170: ; Add missing 'Window commands' entry to the detailed node listing, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 300a4e8e61 084/170: * swsw.el (swsw-delete): Fix when the other tracked window is a minibuffer, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander c153d9a32c 087/170: ; Add version information to customizable variables, ELPA Syncer, 2023/06/28