Dan
Dan

Reputation: 783

How to check current emacs window position relative to other windows

I am using S-<up> and S-<down> to run (enlarge-window) and (shrink-window), respectively.

I would like these keys to be sensitive to the position of the current window relative to others. If my frame is split horizontally into two windows, and the current window is the top one, then I would like S-<up> to run (shrink-window) instead of (enlarge-window).

How do I check the position of the current window relative to the others?

Upvotes: 4

Views: 536

Answers (2)

alinsoar
alinsoar

Reputation: 15793

You can use (window-tree). It will return not only the size of windows, but also their position , as a tree (in emacs' internals the windows of a frame are kept into a tree strucutre).

Upvotes: 2

choroba
choroba

Reputation: 241918

See the function (window-edges). It returns a list of the window's coordinates. Just compare the y-axis value with the other visible windows.

Upvotes: 4

Related Questions