Subject: Re: bug#18590: 24.3.93; Scrolling changes/forgets selection

From: Eli Zaretskii <[email-masked]>
Date: Tue, 30 Sep 2014 20:59:36 +0300

> From: [email-masked] (N. Jackson)
> Date: Tue, 30 Sep 2014 14:42:31 -0300
> 
> At 11:28 -0300 on Tuesday 2014-09-30, Eli Zaretskii wrote:
> 
> > Yes, there's a good reason: a selection in Emacs is always between
> > point and the mark, and when scrolling causes it to go off the
> > displayed portion of the buffer, Emacs moves point to bring it back
> > into view, which changes the selected portion of the text.
> 
> Hmm... I see. But why does point need to be visible?

Emacs always keeps point visible, it's one of the cornerstones of its
display engine.

> It makes sense to me for a program to scroll the window to keep point in
> view when the user moves point; but it doesn't make sense to me for a
> program to move point when the user scrolls the window.

Others will disagree.

It should be possible to implement a mode where point doesn't have to
be in view, but doing so will require non-trivial changes.  Patches
welcome.

> Anyway, if point must be moved, please can it be put back automatically
> where it belongs when the user scrolls the window back and point's
> correct location is once again in view? Consider this a wishlist request.

Try customizing scroll-preserve-screen-position.

> I'd also like to have typing, or any command involving point, scroll the
> window so that the correct location of point comes into view and then act on
> point where it belongs rather than where Emacs has "randomly" moved it.
> Of course this would have to be an optional behaviour, something like a
> (setq point-follows-window nil). Consider it as second wishlist request?

You can have that today if you type "C-SPC" before scrolling.  Then
typing "C-x C-x" after scrolling will get you back where you started.