From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13017 invoked by alias); 16 Jul 2015 14:32:45 -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: 35803 Received: (qmail 6416 invoked from network); 16 Jul 2015 14:32:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,FSL_HELO_BARE_IP_2, RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.0 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Yuri D'Elia Subject: Re: bracketed paste Date: Thu, 16 Jul 2015 16:32:18 +0200 Message-ID: References: <7277.1437023995@thecus.kiddle.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 151.68.54.24 X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.0 In-Reply-To: <7277.1437023995@thecus.kiddle.eu> On 16/07/15 07:19, Oliver Kiddle wrote: > Yuri D'Elia wrote: >> >> Also, I realized sometimes a final newline was tricking me into thinking >> that the command was already enter-ed to the shell (but of course, it >> wasn't). Stripping any final newlines is an improvement. > > Should we perhaps do this in the default widget? That is strip off the > last character if it is a newline. With a default setup, it isn't > actually possible to see the difference between the newline being > inserted and the command being executed but doing nothing for a long > time. In either case, the cursor position is the same. I don't think that removing it only if it's the final character is enough. A string like "\n " is also tricky to spot somehow. I would say a better improvement would be to remove any trailing empty lines. Something like /(\n\s*$)+/. But then again, if you're pasting spaces, the cursor might also end-up being exactly at the beginning of the new line. It kind of depends on what are your expectations on paste. If you're pasting spaces on purpose (for example, to concatenate more commands), you kinda expect paste to be literal. I do this from time to time: paste beginning from here, rest from there, or paste whitespaces in a literal quote (yes!). Terminal-to-terminal pastes are often containing intentional blanks and newlines. What brakes it is mostly paste from a rich web page, where the selection is often aleatory. I'm quite happy with the whitespace trimming on both ends. The fact that I could do the same with the new widget is also good. Although I'm not sure I would need to unquote the string before stripping when a prefix argument is given: in that case my stripping function would break, and I need to know if the argument was given or not to perform the unquote/quote. In that scenario, maybe a "paste_trimmed" style would be better. It avoids the kludges, and it's obvious: either you want literal paste, or you don't want excess whitespace around.