]> git.eshelyaron.com Git - emacs.git/commitdiff
Do not steal primary selection on mark deactivation.
authorChong Yidong <cyd@gnu.org>
Sun, 8 Jul 2012 06:09:21 +0000 (14:09 +0800)
committerChong Yidong <cyd@gnu.org>
Sun, 8 Jul 2012 06:09:21 +0000 (14:09 +0800)
* lisp/simple.el (deactivate-mark): Do not set the primary selection
if another program has acquired it.

Fixes: debbugs:11772
lisp/ChangeLog
lisp/simple.el

index 70894c5fc7b983eb86f5fd2d34f2514ba5b83fc6..8a608ea7b10988fbec5ced366dd55f03a74b9767 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-08  Chong Yidong  <cyd@gnu.org>
+
+       * simple.el (deactivate-mark): Do not set the primary selection
+       if another program has acquired it (Bug#11772).
+
 2012-07-07  Kevin Ryde  <user42@zip.com.au>
 
        * woman.el (woman-strings): Fix double-quote handling (Bug#1151).
index 4527a9da0dc2de382b1991b933b031067a78def4..e6b4a79b9b2563c6a5f935acddabe801177b3509 100644 (file)
@@ -3863,7 +3863,11 @@ run `deactivate-mark-hook'."
       (cond (saved-region-selection
             (x-set-selection 'PRIMARY saved-region-selection)
             (setq saved-region-selection nil))
-           ((/= (region-beginning) (region-end))
+           ;; If another program has acquired the selection, region
+           ;; deactivation should not clobber it (Bug#11772).
+           ((and (/= (region-beginning) (region-end))
+                 (or (x-selection-owner-p 'PRIMARY)
+                     (null (x-selection-exists-p 'PRIMARY))))
             (x-set-selection 'PRIMARY
                              (buffer-substring-no-properties
                               (region-beginning)