4

I saw that bracketed paste mode is automatically enabled in Emacs 25.1 running in a terminal.

But I want to disable this mode. Because this mode adds text like 200~ 201~ to pasted text, bracketed paste mode annoys me.

I have googled But there is no information about disabling bracketed paste mode in emacs.

My development environment is macOS Sierra, and Emacs 25.1. How can I turn off bracketed paste mode?

I frequently copy text from web browser, then paste it into Emacs running in terminal. But something text is added for copied text, e.g. 200~hello, world201~. So these annoying characters reduce my productivity because I have to delete them after pasting text. I want to remove these characters.

6
  • Good question. I see nothing in the manual about it, and C-h n (NEWS) says only this: "Bracketed paste mode is disabled by default, so Emacs automatically enables it at startup if the terminal supports it." I'm not sure how you find out more about it. I filed Emacs bug #24995 to get some more doc about it.
    – Drew
    Nov 23, 2016 at 2:53
  • 1
    Btw: what's your terminal configuration, wnd what's your actual problem? Bracketed pasted mode should "just work"; there should be little reason to disable it.
    – Clément
    Nov 23, 2016 at 5:27
  • 2
    IOW: if Emacs thinks your terminal supports it, but your terminal actually doesn't , then there's a bug in the terminal database; if your terminal does support it, but Emacs prints unwanted characters, then there's a bug in Emacs. In all cases, there's a bug that needs to be fixed; switching bracketed paste mode off would just hide it.
    – Clément
    Nov 23, 2016 at 5:28
  • @Clément I frequently copy text from web browser, then paste it into emacs running in terminal. But something text is added for copied text. ex) 200~hello, world201~
    – Jay Lee
    Nov 23, 2016 at 6:43
  • 1
    Right. So you don't actually want to disable bracketed paste mode at all.
    – Clément
    Nov 24, 2016 at 3:10

2 Answers 2

8

My crystal ball said you should remove

(global-set-key (kbd "M-[") 'previous-multiframe-window)

from your ~/.emacs. You might like to M-x report-emacs-bug and ask for global-set-key to complain when the key sequence conflicts with something in input-decode-map (as is the case here, because the byte sequence ESC [ (which corresponds to the M-[ event) is used by text terminal as a prefix for encoding all kinds of special events).

1
  • Thank you! That thing was driving my crazy since upgrading to 25. May 5, 2017 at 7:15
2

It's not possible to switch it off, as far as I can tell. You'd need a way to get Emacs to write printf "\e[?2004l" to stdout (as discussed here) to disable the feature.

This was introduced in Emacs 25.1, as discussed in bug #24995.

The problem is that you have a keybinding that starts M-[ in your configuration. If you remove that keybinding, Emacs should interpret the bracketed paste characters correctly. It looks like Emacs interprets some of the bracketed paste characters as commands, leading to the 200~hello, world201~ mess.

You may be able to work around the problem by switching to fundamental-mode before pasting, which tends to have fewer keybindings.

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.