Sometimes I have the current buffer in the current window displayed sub-optimally: there is a lot of buffer not shown, and there is a lot of empty space at the bottom below the EOB. E.g.:
- the buffer is 100 lines
- the window is 10 lines
- the point is on the line 3 of the window
- EOB is on the line 5 of the window
so that the bottom 5 lines of the window are empty and the first 95 lines of the buffer are not shown.
I want a function that would "move the window 5 lines up along the buffer" so that
- the EOB is on the bottom line of the window
- the last 10 lines of the buffer are shown
- the point is on the line 8(=3+5) or the window, the value of
(point)did not change
- I do not want the point to move
- I do not want to change window configuration
- I do not want to change the current window size
I am pretty sure something like that exists already, I just cannot figure out how to find it.
Apparently, I need something like this:
(defun sds-improve-window-utilization () "Ensure that there is no empty space below EOB in the current window" (interactive) (when-let ((w (selected-window)) (eob-pos (cadr (pos-visible-in-window-p (point-max) w t))) (point (cadr (pos-visible-in-window-p (point) w t))) (height-c (window-total-height w)) (height-p (window-pixel-height w))) (recenter (/ (- point eob-pos) (/ height-p height-c)))))
I wonder, again, if something like that already exists...