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

From: Federico Tedin <[email-masked]>
Date: Sat, 22 Sep 2018 17:05:19 -0300

After reading more of the code in mouse.el, I found that
mouse-save-then-kill is the only function that allows using the mouse
to set/resize rectangular regions. I'm attaching a patch that fixes
all three use cases for this function: setting the region initially,
resizing the region, and killing the region. I've also made sure it
works correctly when mouse-drag-copy-region is set to t. Hope it helps.
From 317598a579d95ca34def440d2b7789abdcd1ad47 Mon Sep 17 00:00:00 2001
From: Federico Tedin <[email-masked]>
Date: Sat, 22 Sep 2018 16:51:58 -0300
Subject: [PATCH 1/1] Make mouse-save-then-kill work with Rectangle Mark mode

* lisp/mouse.el (mouse-save-then-kill): Make mouse-save-then-kill work
  with rectangular regions, including when mouse-drag-copy-region is
  set to t. (Bug#31240)
---
 lisp/mouse.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index d5c132f484..77e2fe7520 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1606,8 +1606,8 @@ mouse-save-then-kill
       (if mouse-drag-copy-region
           ;; Region already saved in the previous click;
           ;; don't make a duplicate entry, just delete.
-          (delete-region (mark t) (point))
-        (kill-region (mark t) (point)))
+          (funcall region-extract-function 'delete-only)
+        (kill-region (mark t) (point) 'region))
       (setq mouse-selection-click-count 0)
       (setq mouse-save-then-kill-posn nil))
 
@@ -1632,7 +1632,7 @@ mouse-save-then-kill
 	(mouse-set-region-1)
         (when mouse-drag-copy-region
           ;; Region already copied to kill-ring once, so replace.
-          (kill-new (filter-buffer-substring (mark t) (point)) t))
+          (kill-new (funcall region-extract-function nil) t))
 	;; Arrange for a repeated mouse-3 to kill the region.
 	(setq mouse-save-then-kill-posn click-pt)))
 
-- 
2.17.1