From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13217 invoked by alias); 7 Nov 2011 22:36:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29898 Received: (qmail 23026 invoked from network); 7 Nov 2011 22:36:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.co.uk does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1320705065; bh=q9bR/c3WvfU8P/rCQm9p5HvrXSEP0qjA8SBRvaewGrI=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:From:To:Subject:Date:Message-ID; b=Z/Iz58H44zTIdoI1G/qn4OdqrhOhx7n7hcpm3tn/l7CUujdmymiA0uYOdJ6Ew88qyLGNl53hn2H3tK31cO5/IjNzbwhdbTqJkaxBWga3DLg+nTtNPVkkEFNUdn+v9ZvDWYgAbW94G2VhIvmFhdS12ETYbrWAPQLXYiG6SGkZB2k= X-Yahoo-Newman-Id: 967591.66715.bm@smtp132.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: hQWWxjMVM1k2no8lyHThkc5zvM2inJ2Ovsp0HLZIYAbzbyo dTE4bg5EhJQVVbFcBTXNd03VeDXzqI4.9CH3JZmkUk71pzIxr4wIkGfuWPe9 rIt__dYIw439amW3jBGpv3YjawEWuwQYdgo9tbpDPVe9vJZnW2CiSksPKk9n yry_K6_TrMhVFX0rqxRpH85HP.CZX3ozGDf5thXY0Arm7FVu3Y961TofvKb_ eps7.y9L4wqksCUsuIYygEkXr5qQhWFEx8ask6gLJHBhEo9xwz9DRq7eWEnZ W3OKfctqnN1yI1bnpl6MmkwrRXJ57ujm6noYj0W695fiUC6w7OnNLpb_ch7x THvyjFsdZExGYHyfrNYk1_WP4dOF8N53VoTApbkEOZpE- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: bracketed paste Date: Mon, 07 Nov 2011 23:31:04 +0100 Message-ID: <588.1320705064@thecus.kiddle.eu> Has anyone tried enabling the bracketed paste feature of xterm? Basically, when you paste text it is preceded by \e[200~ and terminated with \e[201~. This has the potential to solve some irritations with paste: undo can undo all the pasted text in one go, pasted tab characters won't invoke completion and in vi command mode, pasted text mightn't be treated as vi commands. To handle this, what I've tried so far is putting \e[?2004h at the end of PS1 and PS2 to enable it and \e[?2004l in POSTEDIT so it doesn't remain enabled for other software. I then put together the following zle widget which is, of course, bound to \e[200~. bracketed-paste() { local REPLY paste local end=$'\e[201~' idx=1 while (( idx <= $#end )) && read -k 1; do paste+="${REPLY/$'\r'/ }" [[ $REPLY = $end[idx++] ]] || (( idx = 1 + (#REPLY == #end) )) done if (( NUMERIC )); then LBUFFER+="${(q)paste%$end}" else LBUFFER+="${paste%$end}" fi } The main problem I've found is that you can't paste into the mini- buffer. Is there any way around that? Does it make sense to include this function in Functions/Zle? It would still require people to enable bracketed paste in their xterm. Any other thoughts on what you might do with the pasted text besides pasting it. $LASTWIDGET might be useful here. The function above quotes the text if you supply a numeric argument. This can be useful when pasting, e.g. URLs. In the past, I've used a separate widget that tries to get the buffer with xclip, xselection or xprop. Oliver