1

In macOS in emacs -nw mode, when you paste in some text from another application emacs sometimes misses parts or stops halfway. Often I see a tilde as the last character entered, when there wasnt even a tilde in the incoming text.

I read somewhere that switching to fundamental mode helps, but there's still some 10% of cases where even that doesn't help. Is there anything else one can try to mitigate this issue?

1
  • Please provide a step-by-step recipe to reproduce the problem, starting from emacs -Q (no init file).
    – Drew
    Oct 17, 2019 at 16:02

1 Answer 1

2

When you paste some text into a terminal, the application sees it just as if you had typed the clipboard content. Depending on the software involved (operating system, clipboard mechanism, terminal emulator, Emacs and the system libraries that it uses), this can result in text being lost, or in text being changed because some inputs trigger special behavior. A common kind of special behavior is automatic indentation after line breaks, which increases whatever indentation is in what you paste.

A sure-fire way to avoid trouble is to not paste through the terminal. You can obviously do that by running a GUI Emacs, but it may be possible even in a terminal Emacs. I think that on macOS, as long as Emacs is running locally (as opposed to remotely, e.g. via SSH), you can run the pbpaste command to output the clipboard content.

M-1 M-! pbpaste RET

The analog on systems using X11 is M-1 M-! xsel -b RET or M-1 M-! xclip -sel c RET (for what X11 calls the clipbard; plain xsel or xclip -o gives you the text selected with the mouse but not explicitly copied). This works in a terminal Emacs as long as the environment variables to connect to the X11 display are set (DISPLAY and if needed XAUTHORITY), which is typically the case if you always work in a GUI session, but may not be the case if Emacs is running under Screen or Tmux.

1

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.