From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26628 invoked by alias); 29 Aug 2015 01:34:34 -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: 36322 Received: (qmail 20468 invoked from network); 29 Aug 2015 01:34:32 -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=-1.9 required=5.0 tests=BAYES_00,FSL_HELO_NON_FQDN_1 autolearn=ham autolearn_force=no version=3.4.0 Date: Sat, 29 Aug 2015 03:24:52 +0200 From: Carsten Hey To: zsh-workers@zsh.org Subject: bracketed paste - chopping trailing newlines Message-ID: <20150829012452.GE30848@bosko.stateful.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, 35834 adds stripping a final newline from pasted text in order to enable distinguishing a running command from a paste. Pasting a command with one trailing space now looks exactly like typing the command without the trailing space, which is a very intuitive way to prompt the user to press return to execute the command. If the paste contains more than one trailing newline, this rationale does not apply anymore, i.e., stripping one of these newlines does not imply that the user should press return to execute the command. Pasting multiple trailing newlines can also be intentional, e.g., to build a here document. Therefore I think, that a trailing newline should only be stripped if it does not immediately follow an other newline (what the correct behaviour is if only one newline and no other character is pasted is debatable - and the behaviour of this corner case could be adapted for later releases). Ideally, a stripped newline of a previous paste would be added again if the user pastes again without acknowledging the previous paste first. If this would be implemented, pasting $'foo\n' would result in $'foo' and pasting $'foo\n' and $'bar\n' would result in $'foo\nbar'. The other natural choice to enable distinguishing a running command from a paste is using zle_highlight. This could also avoid the need for the possibly unexpected newline stripping feature. Using paste:standout has been suggested, but in 36160 it has been mentioned that region highlight already uses standout and that there could be some problems with rendering the cursor on basic terminals. An alternative to paste:standout is paste:underline. Given that this one does not suffer from similar possible problems as paste:standout, I would prefer using paste:underline as default and dropping the stripping of trailing newlines (using both would also be an option). I think at least the 'only chop single newlines' change should be implemented (this would need to check if n > 2 and to check the value of wpaste[n-2]). It would be great if this could already be part of zsh 5.1 in to order to minimize the behavioural changes between releases. Regards Carsten