Source: emacs24
Version: 24.1+1-2
Severity: important
Tags: upstream fixed-upstream patch
Forwarded: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11772
Emacs 24 has an important and very annoying regression: a left-click
changes the primary selection, meaning that what is pasted is not
always what is expected (possibly sensitive information!).
To reproduce the bug:
1. Run "emacs -Q" under X.
2. Select something in the Emacs window, e.g. "This buffer".
3. Select something in some other application that supports the
PRIMARY selection, e.g. xterm.
4. Optional: paste the PRIMARY selection somewhere (but not in the
Emacs window opened above). As expected, one can see that the
selection done in (3) is pasted.
5. Click somethere in the Emacs window, with the left button.
As expected, the selection is no longer highlighted.
6. Paste the PRIMARY selection somewhere: it is the one from Emacs
(e.g. "This buffer"), i.e. in (2), that is pasted instead of the
most recent PRIMARY selection from (3).
This bug has been fixed upstream in the trunk:
http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/108950
and the patch (attached) seems to work fine against the Debian
package.
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1,
'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.4-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
-- no debconf information
--- lisp/simple.el 2012-07-07 09:33:28 +0000
+++ lisp/simple.el 2012-07-08 06:09:21 +0000
@@ -3863,7 +3863,11 @@
(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)