zsh-workers
 help / color / mirror / code / Atom feed
* bracketed paste - chopping trailing newlines
@ 2015-08-29  1:24 Carsten Hey
  2015-08-29  5:00 ` Bart Schaefer
  0 siblings, 1 reply; 26+ messages in thread
From: Carsten Hey @ 2015-08-29  1:24 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2015-09-14 21:21 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-29  1:24 bracketed paste - chopping trailing newlines Carsten Hey
2015-08-29  5:00 ` Bart Schaefer
2015-08-30 20:25   ` Carsten Hey
2015-08-30 20:32     ` [patch] 5.0.9 vs 5.1 in source code comments (was: bracketed paste - chopping trailing newlines) Axel Beckert
2015-08-30 20:37     ` bracketed paste - chopping trailing newlines Axel Beckert
2015-08-31  5:47     ` Daniel Shahaf
2015-09-01 23:44       ` Bart Schaefer
2015-09-02 15:41         ` Daniel Shahaf
2015-09-01 23:48     ` Bart Schaefer
2015-09-03 23:59       ` Carsten Hey
2015-09-06  9:52         ` Daniel Shahaf
2015-09-06 13:51           ` Oliver Kiddle
2015-09-06 14:21             ` Bart Schaefer
2015-09-08 10:39               ` Oliver Kiddle
2015-09-10 14:45                 ` Bart Schaefer
2015-09-10 19:11                 ` Daniel Shahaf
2015-09-11 23:07                   ` Bart Schaefer
2015-09-12  0:17                     ` Mikael Magnusson
2015-09-12 15:58                       ` Bart Schaefer
2015-09-14 20:35                     ` Daniel Shahaf
2015-09-14 21:21                       ` Bart Schaefer
2015-09-07  2:11             ` Daniel Shahaf
2015-09-08 23:33             ` Carsten Hey
2015-09-08 23:48               ` Carsten Hey
2015-09-10  8:24                 ` Peter Stephenson
2015-09-07 21:13           ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).