Skip to content

Commit

Permalink
Update crux-transpose-window with other-window
Browse files Browse the repository at this point in the history
Hello,

The current crux-transpose-window uses next-window and previous-window.
I suggest to rather uses other-window.

The difference between those it that other-window will check for the
no-other-window window parameter.

This parameter is by default, not set to any window. It is at the user
or external packages discretion to set it, with display-buffer-alist or
whatever. So essentially, for a default configuration, this commit
changes nothing.

When the user or a package customizes the window display to set it to
some windows, these window will be skipped by functions such as
other-window, windmove, display-buffer-in-direction.

Essentially one may want to narrow the candidates of commands checking
this parameters to gain in predicability and avoid reusing disposables
window, popups or I don't know how to call them but I think you get the
idea.

I will ramble a little and say this parameter is quite confusing since
you may expect the commands of the ctl-x-4-map to uses it, but no. These
commands generally relies on pop-to-buffer and never check the
no-other-window parameter.

So, maybe too specific for crux ?
  • Loading branch information
p1llule authored and bbatsov committed Aug 10, 2021
1 parent 501a43c commit 95f5040
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions crux.el
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,11 @@ Prefix ARG determines if the current windows buffer is swapped
with the next or previous window, and the number of
transpositions to execute in sequence."
(interactive "p")
(let ((selector (if (>= arg 0) 'next-window 'previous-window)))
(while (/= arg 0)
(let ((this-win (window-buffer))
(next-win (window-buffer (funcall selector))))
(set-window-buffer (selected-window) next-win)
(set-window-buffer (funcall selector) this-win)
(select-window (funcall selector)))
(setq arg (if (cl-plusp arg) (1- arg) (1+ arg))))))
(let ((this-win (selected-window))
(this-buffer (window-buffer)))
(other-window arg)
(set-window-buffer this-win (current-buffer))
(set-window-buffer (selected-window) this-buffer)))

(defalias 'crux-swap-windows 'crux-transpose-windows)

Expand Down

0 comments on commit 95f5040

Please sign in to comment.