branch: externals/buffer-expose
commit c47728ed4453ebc1eefbf94fa891f4f9cf5b38a6
Author: Clemens Radermacher <[email protected]>
Commit: Clemens Radermacher <[email protected]>
Don't use other-window which records the switch
---
buffer-expose.el | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 4 deletions(-)
diff --git a/buffer-expose.el b/buffer-expose.el
index c03e6e9..a31c169 100644
--- a/buffer-expose.el
+++ b/buffer-expose.el
@@ -384,8 +384,57 @@ Windows are orderd by `buffer-expose--next-window'."
(push w ws))
(nreverse ws)))
-(defvar buffer-expose--window-list nil)
+(defun buffer-expose--other-window (count &optional all-frames)
+ "Like `other-window' but don't record."
+ (interactive "p")
+ (let* ((window (selected-window))
+ (function (and (not ignore-window-parameters)
+ (window-parameter window 'other-window)))
+ old-window old-count)
+ (if (functionp function)
+ (funcall function count all-frames)
+ ;; `next-window' and `previous-window' may return a window we are
+ ;; not allowed to select. Hence we need an exit strategy in case
+ ;; all windows are non-selectable.
+ (catch 'exit
+ (while (> count 0)
+ (setq window (next-window window nil all-frames))
+ (cond
+ ((eq window old-window)
+ (when (= count old-count)
+ ;; Keep out of infinite loops. When COUNT has not changed
+ ;; since we last looked at `window' we're probably in one.
+ (throw 'exit nil)))
+ ((window-parameter window 'no-other-window)
+ (unless old-window
+ ;; The first non-selectable window `next-window' got us:
+ ;; Remember it and the current value of COUNT.
+ (setq old-window window)
+ (setq old-count count)))
+ (t
+ (setq count (1- count)))))
+ (while (< count 0)
+ (setq window (previous-window window nil all-frames))
+ (cond
+ ((eq window old-window)
+ (when (= count old-count)
+ ;; Keep out of infinite loops. When COUNT has not changed
+ ;; since we last looked at `window' we're probably in one.
+ (throw 'exit nil)))
+ ((window-parameter window 'no-other-window)
+ (unless old-window
+ ;; The first non-selectable window `previous-window' got
+ ;; us: Remember it and the current value of COUNT.
+ (setq old-window window)
+ (setq old-count count)))
+ (t
+ (setq count (1+ count)))))
+
+ (select-window window :no-record)
+ ;; Always return nil.
+ nil))))
+(defvar buffer-expose--window-list nil)
(defun buffer-expose-create-grid (x y)
"Create window grid with X columns, Y rows."
@@ -398,12 +447,12 @@ Windows are orderd by `buffer-expose--next-window'."
(split-window-vertically)
(dotimes (_ (1- x))
(push (split-window-horizontally) ws)
- (other-window 1))
- (other-window 1)
+ (buffer-expose--other-window 1))
+ (buffer-expose--other-window 1)
(push (selected-window) ws))
(dotimes (_ (1- x))
(push (split-window-horizontally) ws)
- (other-window 1))
+ (buffer-expose--other-window 1))
(balance-windows)
(setq buffer-expose--window-list
(nreverse ws))))