Subject: bug#6774: Cut and paste with C-w/mouse-2 not working?

From: Chong Yidong <[email-masked]>
Date: Mon, 02 Aug 2010 16:59:06 -0400

David De La Harpe Golden <[email-masked]> writes:

> Does your way work properly in a multi-window context on its own,
> though?  I suspect not -that it will deactivate-mark on "boring"
> restored active regions (see below) and set the selection to the
> "boring" region, confounding user expectations, because the restored
> region could be non-empty.
>
> The thing is, if you use focus-follows-mouse between frames, or mouse
> autoselect-window between emacs windows, you select_window without
> going through "normal channels", so trying to do _anything_ smart in
> deactivate-mark tends to break - e.g. the mark is being deactivated in
> a window different to the last window bound to the selection. The selx
> branch just forces the selection to a string if it's lazy-bound to a
> window and emacs still owns it on deactivate mark.

You're right, the window-switching code needs to be able to change the X
selection buffer if switching into a window where there is an active
region.

But with this change, is there any case that my proposal---i.e. saving a
copy before before-change-functions, for deactivate-mark to refer to if
the region ends up empty---would not handle?  Assuming that the current
buffer and the active region can only change as a result of a user
command or window switching, those are the only cases that we have to
cover.