GidiomGates · 2022-12-19 15:00
Hello, I want to customize the key combinations to enlarge the window. I already customized to enlarge and enlarge horizontally with `C-s-<top>` and `C-s-<right>`. But now I want it to be smarter. I mean, depending on the position of the window, I would like to call other arrows to make the window larger or smaller.
Any ideas to start?
yurikhan · 2022-12-19 16:00
Start by defining the desirable behavior. For example, your frame is split into three windows vertically and the one in the middle is selected.
Window 1
---------------
Window 2█
---------------
Window 3
Which of the two adjacent separators will C-s-<up>/<down> move, and what do you do if you want to move the other one?
GidiomGates · 2022-12-19 16:08
The idea is that be the more intuitive in possible. I mean, in that example, the arrow up, will enlarge the window up (actually reduce above window). And arrow down, will enlarge to down (actually reduce the below window). I mean, the arrows must be intuitive.
yurikhan · 2022-12-19 16:34
Well, this just shows “intuitive” is subjective. For example, I would expect the up and down arrows to be inverse of each other, so if up reduces the above window, down would enlarge it back.
But maybe you could start with something like this:
(defun my-window-enlarge-to-above ()
(interactive)
(when-let ((w (window-in-direction 'above)))
(window-resize w -1)))
(defun my-window-enlarge-to-below ()
(interactive)
(when-let ((w (window-in-direction 'below)))
(window-resize nil 1)))
(defun my-window-reduce-from-above ()
(interactive)
(when-let ((w (window-in-direction 'above)))
(window-resize w 1)))
(defun my-window-reduce-from-below ()
(interactive)
(when-let ((w (window-in-direction 'below)))
(window-resize nil -1)))
GidiomGates · 2022-12-19 17:18
Thanks!! I'll try.
rswgnu · 2022-12-19 18:24
Try HyControl in the Hyperbole package. It has a sticky prefix arg and bindable keys that let you adjust window sizes in any desired increments, move buffers around in windows or frames and much more. No need to reinvent the wheel.
GidiomGates · 2022-12-19 23:06
ok, the hyperbole package is new to me. I read some docs and still don't understand haha but I'll try that.