Subject: bug#31905: detection of edge of highlighted text by mouse-drag-and-drop-region

From: Tak Kunihiro <[email-masked]>
Date: Wed, 20 Jun 2018 08:25:41 +0900 (JST)

I found bug on `mouse-drag-and-drop-region'.  The
`mouse-drag-and-drop-region' does not recognize the beginning and the
end of highlighted text as pre existing region.

1: emacs -Q
2: (setq mouse-drag-and-drop-region 'meta)
2: Select text on a buffer and have a region. Let's assume `This buffer' is highlighted.
3: Drag and drop the text onto the first character of the region, that is `T'.
4: Then the text `This buffer' would be disappeared.

I attach a patch to fix the bug.  This patch is relative to 26.1.50.

* Commit log

Author: Tak Kunihiro <[email-masked]>

    Fix bug of 'mouse-drag-and-drop-region' to detect edges of region
    
    * lisp/mouse.el
    (mouse-drag-and-drop-region): Detect both the beginning and the
    end of character of region during dragging text.
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5c9056fb43..f749d12054 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -2515,9 +2515,9 @@ mouse-drag-and-drop-region
             (setq drag-but-negligible
                   (and (eq (overlay-buffer mouse-drag-and-drop-overlay)
                            buffer-to-paste)
-                       (< (overlay-start mouse-drag-and-drop-overlay)
+                       (<= (overlay-start mouse-drag-and-drop-overlay)
                           point-to-paste)
-                       (< point-to-paste
+                       (<= point-to-paste
                           (overlay-end mouse-drag-and-drop-overlay)))))
 
           ;; Show a tooltip.