Subject: Re: bug#31240: 26.1; mouse-save-then-kill does not kill rectangles

From: Federico Tedin <[email-masked]>
Date: Sun, 23 Sep 2018 19:23:13 -0300

> Thanks, this looks good.  I think we also need a similar change for
> function "mouse-drag-and-drop-region", which is used when the variable
> of the same name is non-nil.  For example, the following recipe
> exposes it:
>
> M-x set-variable RET mouse-drag-and-drop-region RET t RET
> M-< C-SPC M-f C-n C-x SPC
> Drag the rectangle region with the mouse, and its shape is ignored
>
> Hopefully we can apply the same kind of change in that function too.

You're right about mouse-drag-and-drop-region, it doesn't work
correctly when using rectangular regions. After taking a look at the
code, I managed to fix two things: the dragged text now has the
correct rectangular contents (but the original text is incorrectly
deleted using a normal region), and the tooltip displaying the dragged
text also shows the correct contents.

To fix the rest of the functionalities, I would need to know the
recommended way of handling some of the details of how
mouse-drag-and-drop-region is implemented:

- The dragged region is tracked using an overlay. From what I
  understand, this is a problem since overlays only handle regions
  with a single beginning and end, and rectangles have one or more of
  those.

- In order to check if the dragged text is read-only, the function
  "next-single-char-property-change" is used. This function has the
  same problem as the overlay, as it assumes the region is contiguous.

I'm thinking both problems could be solved by using a list of overlays
instead of just one, creating them from the result of calling
"region-bounds".  Then, the rest of the function could be adapted to
use the overlay list.