all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* splitting a window at point
@ 2018-04-17  0:23 James K. Lowden
  2018-04-19 18:13 ` Tomas Nordin
       [not found] ` <mailman.12737.1524161596.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: James K. Lowden @ 2018-04-17  0:23 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread
* splitting a window at point
@ 2018-04-17  6:32 martin rudalics
  0 siblings, 0 replies; 5+ messages in thread
From: martin rudalics @ 2018-04-17  6:32 UTC (permalink / raw)
  To: jklowden; +Cc: help-gnu-emacs

 > How, then, to compute the cursor's window position?

Have a look at the specification of 'mouse-split-window-vertically'.
It should provide everything you need in this regard.

martin



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-20 18:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-17  0:23 splitting a window at point James K. Lowden
2018-04-19 18:13 ` Tomas Nordin
     [not found] ` <mailman.12737.1524161596.27995.help-gnu-emacs@gnu.org>
2018-04-20  0:42   ` James K. Lowden
2018-04-20 18:07     ` Tomas Nordin
  -- strict thread matches above, loose matches on Subject: below --
2018-04-17  6:32 martin rudalics

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.