3

Emacs 25.1.50, GTK+ version 3.18.9 on GNU/Linux, version 4.4. Gnome-terminal as xterm terminal emulator.

When using clipboard (as in, I copy some text from my operating system/browser), and paste it in Emacs GUI version, it works fine. The GUI Emacs works in pair with the clipboard manager, which is supported by many X desktop environments.

However, when I'm using Emacs with emacs -nw, the clipboard seems to be inaccesible from the terminal version of Emacs. When reading the Emacs documentation about clipboard, I tried to let the console Emacs communicate with the clipboard with the following settings:

(setq
 x-select-enable-clipboard t
 x-select-enable-primary t
 x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)
 x-stretch-cursor t)

Without any luck. Other packages like simpleclip will not work in terminal Emacs too. So I'm out of ideas. I'm not sure if this is related with the terminal itself of the console-based Emacs.

1

1 Answer 1

3

The NEWS for 25.1 says:

*** Killing text now also sets the CLIPBOARD/PRIMARY selection
in the surrounding GUI (using the OSC-52 escape sequence).  This only works
if your xterm supports it and enables the 'allowWindowOps' options (disabled
by default at least in Debian, for security reasons).

Similarly, you can yank the CLIPBOARD/PRIMARY selection (using the OSC-52
escape sequence) if your xterm has the feature enabled but for that you
additionally need to add 'getSelection' to 'xterm-extra-capabilities'.

So you probably need to set allowWindowOps in your xterm's options (e.g. via xrdb). For other terminal emulators than xterm itself, your mileage will vary.

Another way to attack the problem is with the xclip package, available in GNU ELPA, which uses an external program called xclip.

3
  • Thanks for the suggestion. How did you figured out that the answer might be in the NEWS section of the 25.1 release? I added xterm*allowWindowOps: true in my .Xresources and .Xdefault, restarted it, without any luck. Do you have another suggestion?
    – ReneFroger
    May 14, 2016 at 18:37
  • How widespread is support for those escapes in other terminals?
    – PythonNut
    May 14, 2016 at 20:25
  • 2
    I knew because I installed the patch that added this support. See also stackoverflow.com/questions/31223710/…. The recipe I provide there is for xterm rather than for gnome-terminal. My guess is that gnome-terminal does not pay attention to X resources. I don't know if it implements those OSC-52 escapes either.
    – Stefan
    May 14, 2016 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.