From: Chong Yidong Date: Sun, 8 Jul 2012 06:09:21 +0000 (+0800) Subject: Do not steal primary selection on mark deactivation. X-Git-Tag: emacs-24.2.90~1199^2~137 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d75be97d549b7264098ff19f8941a0dd80bde080;p=emacs.git Do not steal primary selection on mark deactivation. * lisp/simple.el (deactivate-mark): Do not set the primary selection if another program has acquired it. Fixes: debbugs:11772 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 70894c5fc7b..8a608ea7b10 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-07-08 Chong Yidong + + * simple.el (deactivate-mark): Do not set the primary selection + if another program has acquired it (Bug#11772). + 2012-07-07 Kevin Ryde * woman.el (woman-strings): Fix double-quote handling (Bug#1151). diff --git a/lisp/simple.el b/lisp/simple.el index 4527a9da0dc..e6b4a79b9b2 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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)