[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
splitting a window at point
From: |
James K. Lowden |
Subject: |
splitting a window at point |
Date: |
Mon, 16 Apr 2018 20:23:59 -0400 |
It seems like an obvious function: I'd like to split a window
vertically, such that the top of the lower window is positioned where
the cursor is. If I'm on line 6, the top window will have 6 lines, and
the bottom window gets the rest. I (would) do this from time to time,
to leave a function definition in the top window while in the lower
window I operate on the code that uses it.
split-window-vertically takes an optional argument for the top (or
bottom) window size. So far, so good. C-u C-x 2 does indeed open the
top window with 4 lines.
How, then, to compute the cursor's window position?
move-to-window-line moves to the line, but there's no get-window-line.
what-cursor-position reports the buffer position, not the window
location. I could compute the cursor's window position from it if I
knew the window's buffer position, but apropos returns no function
for "window" that mentions buffer position in its description.
Do I "just" save the curent cursor position, jump to window line 1, get
its buffer position, jump back, and take the difference? I guess that
will work, but I'd rather not move the cursor just to compute its
location.
What am I overlooking?
--jkl
- splitting a window at point,
James K. Lowden <=