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

From: Drew Adams <[email-masked]>
Date: Tue, 30 Sep 2014 08:06:48 -0700 (PDT)

> > 4. Scroll the window with the scroll bar or the mouse.
> > The selection changes as the window is scrolled up and down.
> 
> 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.

Yes, it's well known.  But IMO not ideal behavior.

The same thing does not happen if you select with the mouse (e.g.
drag the selection past the window bottom.  And it does not happen
if you set mark and then use C-v to move past the window bottom.

The problem is not that point is kept in the window - that is
desirable.  The point is the lack of a mark at the other end, so
the selected text shrinks (that's not really a problem, since what
is no longer selected is off-screen anyway), and you cannot use
C-x C-x to get back the region you had.  That loss of the original
region is the problem.  With the other methods I just mentioned,
you can use C-x C-x to get the region back.

I see the problem only when the scroll bar is used.  Not sure
what the OP meant by "or with the mouse".  Perhaps he meant
a window-scrolling mouse.  I don't see the problem when I drag
the selection using the mouse, at least.

And if I select a bit of text and then use the mouse wheel to
scroll the window I don't see the problem either.  In that case,
the scrolling immediately deselects the text, unlike the case
when I use the scroll bar.