[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swsw c2c579a3c9 061/146: Construct multi-character IDs wit
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swsw c2c579a3c9 061/146: Construct multi-character IDs without pre-computing all possible IDs |
Date: |
Wed, 25 May 2022 02:59:44 -0400 (EDT) |
branch: elpa/swsw
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)
- [nongnu] elpa/swsw 4c84ca310f 016/146: ; Update README to reflect recent changes, (continued)
- [nongnu] elpa/swsw 4c84ca310f 016/146: ; Update README to reflect recent changes, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw a816f208e9 005/146: Simplify the format of 'swsw-window-list', ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw f9a901c809 004/146: * swsw.el (swsw-id-chars-base): Remove erroneous quote, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 96809a6cae 019/146: Add the ability to change the way window IDs are displayed, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw c08a9b1e58 024/146: ; Fix a docstring, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw b6277eb31f 037/146: ; Indicate that version 1.1 is still in development in the NEWS file, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw a5b25e075f 032/146: Allow setting the scope to the selected frame, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 082e03382e 033/146: * swsw.el (swsw-select): Ensure 'swsw-after-select-hook' runs., ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 40f7a25f82 047/146: ; Add license information to the title page of the Info node, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 3a9848deac 042/146: Add an Info node for the package, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw c2c579a3c9 061/146: Construct multi-character IDs without pre-computing all possible IDs,
ELPA Syncer <=
- [nongnu] elpa/swsw 7d82ffeef4 076/146: ; Small modifications to the NEWS file, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 4ceacd0330 132/146: Indicate that some functions are for interactive use only, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw eba70478e0 065/146: Update window information after 'swsw-scope' is customized, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 51fcc776bd 081/146: ; Reorganize swsw.el, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 2f7500636d 098/146: ; Add 'swsw' to .gitignore, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw db5cd237a7 125/146: ; Documentation improvements, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 6a70afa84f 097/146: ; Documentation fixes, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 384dae5d45 128/146: ; Move local mode declaration to the top of NEWS, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 220c023a2a 088/146: ; Update copyright years, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 73a241cf38 064/146: Ensure 'swsw-id-chars' is set correctly when customized, ELPA Syncer, 2022/05/25