Subject: Re: battle with x-clipboard vs. Chinese

From: David De La Harpe Golden <[email-masked]>
Date: Sun, 25 Jul 2010 04:58:22 +0100

On 25/07/10 02:28, [email-masked] wrote:
> And the most scary thing of all is now things that I kill with C-k in
> emacs are not necessarily what Shift-Insert will now paste in xterm.

This is a likely separate issue to the encoding problem and expected 
behaviour.   Recently a decision was made to make emacs act more like 
and play nicer with more recent x11 applications in the area of cut and 
paste.  xterm is ...not a recent application in this respect.

Things killed in emacs presently go to the _system clipboard_, but 
Shift-Insert in xterm inserts the "x11 primary selection" (unless you 
reconfigure it to use the clipboard).

The below does not directly address encoding problems (though step 3 
will mask the known encoding bug):

*** The new settings are only a revised default, you can still 
reconfigure emacs to act like it used to.  This will mean it won't work 
well with more recent x11 applications anymore, much like the way xterm 
doesn't work well with them.  Of course, you may not care.

1. M-x customize-group killing

Turn off x-select-enable-clipboard
Turn on x-select-enable-primary
Turn off select-active-regions

2. M-x customize-group mouse

Turn on mouse-drag-copy-region

3. Add the following to your ~/.emacs:

(global-set-key [mouse-2] 'mouse-yank-at-click)

**** various forms of xterm reconfiguration are also possible, though 
may not prove satisfactory. Using gnome-terminal (or xfce4-terminal or 
konsole, etc.) might be a better option.

Firstly, you can easily make xterm use the clipboard, but then it uses 
it all the time:  Hold down ctrl and middle mouse button on the xterm 
window. Select menu option "Select to Clipboard".  If you like that, 
making that permanent involves setting X resource 
XTerm.selectToClipboard as per the xterm manual.

http://www.davidsimmons.com/soft/xtermhacks/#copynpaste has another take 
on the problem with xterm in this area, and offers some more advanced 
hackery for changing xterm's behaviour.