From d75be97d549b7264098ff19f8941a0dd80bde080 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sun, 8 Jul 2012 14:09:21 +0800 Subject: [PATCH] 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 --- lisp/ChangeLog | 5 +++++ lisp/simple.el | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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) -- 2.11.4.GIT