Subject: bug#18939: 24.4; middle-click sometimes pastes data other than the PRIMARY selection

From: Vincent Lefevre <[email-masked]>
Date: Sun, 4 Jan 2015 03:23:37 +0100

[Cc to the Debian bug]

On 2014-12-30 12:45:12 +0200, Riku Saikkonen wrote:
> I tried to trace where the bug occurs, and got as far as this:
> 
> mouse-drag-track contains the lines
> 
> 	  ;; Otherwise, run binding of terminating up-event.
>           (deactivate-mark)
> 	  (if do-multi-click
> 	      (goto-char start-point)
> 	    (unless moved-off-start
> 	      (pop-mark)))
> 
> (lines 858-863 of mouse.el in Emacs 24.4.1)
[...]

How about locally setting select-active-regions to nil for
(deactivate-mark)? See attached patch, which seems to work
for me, though I don't know all the consequences.

It is inspired from the patch suggested at

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6872#8

and the one that was really applied as
1c409d0b963ebdb1f48b90ddce85c56d989bee5f.

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index e267418..2afe313 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -856,7 +856,8 @@ DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by
 		     (copy-region-as-kill (mark) (point)))))
 
 	  ;; Otherwise, run binding of terminating up-event.
-          (deactivate-mark)
+          (let (select-active-regions)
+            (deactivate-mark))
 	  (if do-multi-click
 	      (goto-char start-point)
 	    (unless moved-off-start