4

This is a long-standing problem that I haven't found a solution for months. I sometimes copy text or snippet from somewhere relse and paste into my emacsclient in the Terminal by Ctrl + Shift + V (Gnome Terminal, Linux). Emacs frequently interferes with this pasting by triggering arbitrary commands. This breaks the pasting job, and may also be a security risk.

For example, this content:

head -n1 ucsc.refseq.txt >refseq.sorted.txt 

would be trucated to head -n1 ucsc.re and send eq.txt >re to some other command (i.e. switch buffer). The eq.sorted.txt disappears. And the fs parts were interpreted as some command/mt macro that I can't find from any exposed emacs function.

I tried with clipboard-yank, pasting produced different result but still not complete content I want to paste.

So, how do I make emacs paste literally all of my clipboard content, without triggering anything?

If it helps anything: my emacs version 24.5 with spacemacs configuration.

Update:

Some more background information: The problem here is that I use my local computer to select and copy text. Then I paste into emacsclient with the ssh. This means the my local clipboard's content has to be transferred to the remote server letter by letter, not the normal way of clipboard handling. And that causes the problem.

2

2 Answers 2

1

Try this in a terminal session on your local machine:

xsel -bo | ssh you@remoteHost 'cat - > /tmp/pasted'

Then in your remote terminal emacsclient session:

C-x i /tmp/pasted RET

to insert /tmp/pasted at point.

1

Good news: this problem should be solved in Emacs-25 where we support the so-called "bracketed paste" mode: Emacs asks the terminal emulator to surround every paste with a special escape sequence, which Emacs can then recognize so as to treat the pasted text as just that (i.e. text) rather than a sequence of key presses.

IOW just upgrade to Emacs-25 and this problem should disappear (apparently this functionality has been supported by most terminal emulators for a while already, so you probably don't need to update this part).

Your Answer

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

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