window-list when it builds its list of windows using
aw-window-list and sorts the windows using
I tried just bypassing the sorting entirely by redefining
(defun aw-window< (wnd1 wnd2) t)
ace-window has its own window ring, and uses that somehow when numbering the windows. So after switching, the order is different!
That said, it's easy enough to swap the row/column logic in
(defun aw-window< (wnd1 wnd2)
"Return true if WND1 is less than WND2.
This is determined by their respective window coordinates.
This modification of what's in ace-window.el numbers the
windows in a row-major way: left to right, top down."
(let* ((f1 (window-frame wnd1))
(f2 (window-frame wnd2))
(e1 (window-edges wnd1))
(e2 (window-edges wnd2))
(p1 (frame-position f1))
(p2 (frame-position f2))
(nl (or (null (car p1)) (null (car p2)))))
(cond ((and (not nl) (< (car p1) (car p2)))
((and (not nl) (> (car p1) (car p2)))
;; You can read "car" below as "the upper left x-coordinate"
;; and "cadr" as "the upper left y-coordinate". The usage here
;; is swapped from ace-window.el to change column-major
;; ordering to row-major.
((< (cadr e1) (cadr e2))
((> (cadr e1) (cadr e2))
((< (car e1) (car e2))
...which is identical to the source code, except for exchanging the
I haven't fully figured out why the first approach -- using an always-true or always-nil predicate -- doesn't work, but it's easy enough to just evaluate the above. I'm sure there's a more elegant way to handle this override but this works. shrug