[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iwindow 63426c55a9 08/13: Make window keys more predictabl
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iwindow 63426c55a9 08/13: Make window keys more predictable |
Date: |
Sun, 27 Nov 2022 16:01:12 -0500 (EST) |
branch: elpa/iwindow
commit 63426c55a94df025fcaaac8917c09708db6c768f
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Make window keys more predictable
---
iwindow.el | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/iwindow.el b/iwindow.el
index b1a9c2dfae..b06464f51a 100644
--- a/iwindow.el
+++ b/iwindow.el
@@ -96,14 +96,18 @@ CALLBACK and revert the changes it has done."
(defface iwindow-highlight-fringe '((t :background "blue"))
"`fringe' face for highlighted windows.")
-(defun iwindow--make-decision-tree (windows start end)
+(defun iwindow--make-decision-tree (windows start end predicate)
"Make a decision tree from window in WINDOWS from START to END.
-Return an object OPTION, where OPTION is either a window, or a list of
-form (OPTION...), whose length of no more than the length of
+Don't include windows for which PREDICATE returns nil.
+
+Return an object OPTION, where OPTION is either a window, nil, or a
+list of form (OPTION...), whose length of no more than the length of
`iwindow-selection-keys'."
- (if (eql (- end start) 1)
- (aref windows start)
+ (if (= (- end start) 1)
+ (let ((window (aref windows start)))
+ (when (funcall predicate window)
+ window))
(let ((result nil)
(option-count (length iwindow-selection-keys)))
(dotimes (i option-count)
@@ -112,8 +116,9 @@ form (OPTION...), whose length of no more than the length of
(s (min (+ start (* i max-descendent-option-count))
end))
(e (min (+ s max-descendent-option-count) end)))
- (unless (eql s e)
- (push (iwindow--make-decision-tree windows s e) result))))
+ (unless (= s e)
+ (push (iwindow--make-decision-tree windows s e predicate)
+ result))))
(nreverse result))))
(defun iwindow--decorate-windows (tree payload)
@@ -162,7 +167,7 @@ Return the window chosen."
(redraw-display)
(while (not option)
(let ((key (read-key)))
- (if (eql key ?\C-g)
+ (if (= key ?\C-g)
(keyboard-quit)
(if-let ((choice (alist-get key choices)))
(setq option choice)
@@ -181,15 +186,16 @@ WINDOW and ignore WINDOW when PREDICATE returns nil."
(user-error
"Atleast two keys needed to select window, please customize `%S'"
'iwindow-selection-characters))
- (let ((windows (if predicate
- (seq-filter predicate (window-list))
- (window-list))))
- (when windows
- (if (cdr windows) ; (> (length windows) 1)
- (let* ((tree (iwindow--make-decision-tree
- (vconcat windows) 0 (length windows))))
- (iwindow--ask tree))
- (car windows)))))
+ (let* ((windows (window-list nil nil (frame-first-window)))
+ (candidates (if predicate
+ (seq-filter predicate windows)
+ windows)))
+ (when candidates
+ (if (cdr candidates) ; (> (length candidates) 1)
+ (iwindow--ask (iwindow--make-decision-tree
+ (vconcat windows) 0 (length windows)
+ predicate))
+ (car candidates)))))
(defun iwindow-show-keys-on-mode-line (windows callback)
"Change mode line of windows to show the keys to choose the window.
- [nongnu] elpa/iwindow 89989ad071 10/13: Minor cleanup, (continued)
- [nongnu] elpa/iwindow 89989ad071 10/13: Minor cleanup, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow fc092c6b64 12/13: Lower Emacs minimum requirement to 24.3, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow cbbcdb32b2 05/13: Suppress runtime warning, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow f7b47e3bd8 04/13: Show keys for minibuffer on minibuffer, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow 13b9c558bf 11/13: Replace cl-labels with named-let, use Compat if needed, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow 144c402d5f 13/13: Add .dir-locals.el, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow 6c5ea91142 02/13: Allow to use any arbitrary face to highlight, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow 285f40ff09 01/13: Add iwindow-select, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow a32c522f80 06/13: Add iwindow-delete and iwindow-delete-others, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow f5cf9ed724 07/13: Don't show raw key code on unbound key, ELPA Syncer, 2022/11/27
- [nongnu] elpa/iwindow 63426c55a9 08/13: Make window keys more predictable,
ELPA Syncer <=