zsh-workers
 help / color / mirror / code / Atom feed
* counterintuitive behavior of zle_bracketed_paste
@ 2017-06-11 10:37 Peter Backes
  2017-06-11 15:39 ` Daniel Shahaf
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Backes @ 2017-06-11 10:37 UTC (permalink / raw)
  To: zsh-workers

Hello,

The README says in section "Incompatibilities between 5.0.8 and 5.1": 
'Now, the new "bracketed paste mode" treats all the pasted text as 
literal characters.  This means, in particular, that a newline is 
simply inserted as a visible newline; you need to hit Return on the 
keyboard to execute the pasted text in one go."

While backeted paste mode is certainly a good thing, this behavior is 
very counterintuitive.  If the last pasted character is a return, the 
command should instead be executed instantly.  Users who do not want to 
execute instantly can simply not paste a return on the last line, as 
before.  Please change zsh accordingly.

Please mail me directly if you reply as I am not subscribed to the list.

Best wishes
Peter
-- 
Peter Backes, rtc@helen.PLASMA.Xg8.DE


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

* Re: counterintuitive behavior of zle_bracketed_paste
  2017-06-11 10:37 counterintuitive behavior of zle_bracketed_paste Peter Backes
@ 2017-06-11 15:39 ` Daniel Shahaf
  2017-06-11 16:55 ` Frank Terbeck
  2017-06-11 17:55 ` Bart Schaefer
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2017-06-11 15:39 UTC (permalink / raw)
  To: Peter Backes; +Cc: zsh-workers

Peter Backes wrote on Sun, 11 Jun 2017 12:37 +0200:
> While backeted paste mode is certainly a good thing, this behavior is 
> very counterintuitive.  If the last pasted character is a return, the 
> command should instead be executed instantly.  Users who do not want to 
> execute instantly can simply not paste a return on the last line, as 
> before.  Please change zsh accordingly.

You can change the behaviour locally by overriding the bracketed-paste
widget in your zshrc:

[[[
bracketed-paste() {
  local PASTED # as in bracketed-paste-magic
  zle .bracketed-paste PASTED
  # mimic built-in widget's functionality
  (( NUMERIC == 0 )) || PASTED=${(q-)PASTED}
  zle -f 'yank'; YANK_START=$#LBUFFER; (( YANK_END = $#LBUFFER + $#PASTED ))
  LBUFFER+=$PASTED
  if [[ $PASTED[-1] == $'\n' ]]; then
    zle accept-line
  fi
}
zle -N bracketed-paste
]]]

I'll let others comment on your second question of changing the defaults.

Cheers,

Daniel

> Please mail me directly if you reply as I am not subscribed to the list.


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

* Re: counterintuitive behavior of zle_bracketed_paste
  2017-06-11 10:37 counterintuitive behavior of zle_bracketed_paste Peter Backes
  2017-06-11 15:39 ` Daniel Shahaf
@ 2017-06-11 16:55 ` Frank Terbeck
  2017-06-11 17:55 ` Bart Schaefer
  2 siblings, 0 replies; 4+ messages in thread
From: Frank Terbeck @ 2017-06-11 16:55 UTC (permalink / raw)
  To: Peter Backes; +Cc: zsh-workers

Hi,

Peter Backes wrote:
[...]
> While backeted paste mode is certainly a good thing, this behavior is 
> very counterintuitive.  If the last pasted character is a return, the 
> command should instead be executed instantly.  Users who do not want to 
> execute instantly can simply not paste a return on the last line, as 
> before.  Please change zsh accordingly.

Personally, I disagree. I find the new behavior to be a significant
improvement. This way I can paste anything, multiple lines even, into
my shell, make adjustments if so needed and then deliberately execute
whatever is in the buffer. This also takes care of the occasional
accidental paste.

Since automatic execution is possible to activate via configuration,
as Daniel has shown, the defaults should be left as they are.


Regards, Frank


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

* Re: counterintuitive behavior of zle_bracketed_paste
  2017-06-11 10:37 counterintuitive behavior of zle_bracketed_paste Peter Backes
  2017-06-11 15:39 ` Daniel Shahaf
  2017-06-11 16:55 ` Frank Terbeck
@ 2017-06-11 17:55 ` Bart Schaefer
  2 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2017-06-11 17:55 UTC (permalink / raw)
  To: Peter Backes, zsh-workers

On Jun 11, 12:37pm, Peter Backes wrote:
}
} While backeted paste mode is certainly a good thing, this behavior is 
} very counterintuitive.  If the last pasted character is a return, the 
} command should instead be executed instantly.

Thanks for your input, but we had quite a long discussion about this on
the mailing list and the consensus was for the current behavior.

IIRC the case that brought us to this conclusion was what happens when
the paste is in the middle of the edit buffer rather than at a fresh
prompt or at the end of the buffer; i.e., when $RBUFFER is not empty.
The contents of the existing buffer as well as the presence of newlines
in the pasted text, matters, and it is better to have one consistent
paste behavior that does the least surprising thing in all cases.

As Daniel has already mentioned, there are ways to customize around
this if you strongly feel that a different behavior is better for you.
In addition to his suggested function, the bracketed-paste-magic widget
provides several hooks for modifying bracketed-paste behavior.

E.g.:

    autoload bracketed-paste-magic
    zle -N bracketed-paste bracketed-paste-magic

    bp-run-immediate () {
	[[ "$PASTED" = *$'\n' ]] && zle -U $'\n'
    }
    zstyle :bracketed-paste-magic paste-finish bp-run-immediate


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

end of thread, other threads:[~2017-06-11 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-11 10:37 counterintuitive behavior of zle_bracketed_paste Peter Backes
2017-06-11 15:39 ` Daniel Shahaf
2017-06-11 16:55 ` Frank Terbeck
2017-06-11 17:55 ` Bart Schaefer

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).