Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bracketed paste - chopping trailing newlines
- X-seq: zsh-workers 36429
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Carsten Hey <carsten@xxxxxxxxxx>
- Subject: Re: bracketed paste - chopping trailing newlines
- Date: Sun, 6 Sep 2015 09:52:24 +0000
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=18ae7gG1y1g7YEi8 WIw2LnlQlkw=; b=0I+fqKuKe9nChQ8O8f7JPK9UFx44WaF/KF7R/x5AI8j8I2z4 tLc5NOAT01OOZYpJJ8GkdrHxHk/8s25Hml2e0RrPDhigRTpx8X0f7fLlLhd5hzC1 b4FYKoNpSAl5ZBRXYny8MbsvY2xNQyRBeb6iDtduuRLHxpM9AcD5dRafI4A=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=18ae7gG1y1g7YEi 8WIw2LnlQlkw=; b=SpSPPhHbM5clzPlM/eKz7pop7RwoqQkgbpb8+MQ4w5dvKyl ERADIcJHPCt1BxUfr3ry0Tk7DGHVBZkMUrDH70BjiHS+ntxQAPrlpeR8zMaehOMQ 42wPStvsy3tbUEX9a0/+u+cM1eE0DcWA3+p2SGva9/N6apRCF+fvCRO0s0yY=
- In-reply-to: <20150903235936.GH30848@bosko.stateful.de>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20150829012452.GE30848@bosko.stateful.de> <150828220057.ZM14497@torch.brasslantern.com> <20150830202530.GF30848@bosko.stateful.de> <150901164827.ZM2480@torch.brasslantern.com> <20150903235936.GH30848@bosko.stateful.de>
Carsten Hey wrote on Fri, Sep 04, 2015 at 01:59:36 +0200:
> An other main paste feature, not running a pasted command without user
> interaction, would be disabled by this (which makes it, for my private
> setup, a good candidate for being activated if needed by some currently
> unused function key).
>
> Btw., I also think that highlighting is sufficient to alert the user
> that no command is running - that it vanishes if a command runs makes
> this pretty clear for the second time, and the first time the previously
> unseen highlighing should catch the attention of the users and make them
> check what happend. zle -M ... seems to be a bit too verbose for
> a default behaviour.
I'm attaching a patch and a zshrc that together demonstrate the proposed
behaviour. To test them, apply the patch, run the resulting 'zsh -f',
and source the script.
I propose to make the _resulting behaviour_ the default in 5.1.1. However,
before I spend time on rewriting the attached patch entirely in C, I'd
like to ensure we have consensus for making this change.
The behaviour is: (a) pastes are never executed until <Enter> is pressed;
(b) zle_highlight is set; (c) newlines are removed only at <accept-line>.
Cheers,
Daniel
diff --git a/ChangeLog b/ChangeLog
index 7b98bfe..af3a4a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -366,6 +366,7 @@
* 36125: Src/Zle/zle_hist.c: don't set history context in get-line
+ [reverted post-5.1]
* 35834 (tweaked): Src/Zle/zle_misc.c: strip a final newline from
pasted text: inserting is hard to tell apart from accepting it
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 2d18628..c1005dc 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -787,12 +787,6 @@ bracketedpaste(char **args)
zmult = 1;
if (region_active)
killregion(zlenoargs);
- /* Chop a final newline if its insertion would be hard to
- * distinguish by the user from the line being accepted. */
- else if (n > 1 && zlecontext != ZLCON_VARED &&
- (zlecs + (insmode ? 0 : n - 1)) >= zlell &&
- wpaste[n-1] == ZWC('\n'))
- n--;
yankcs = yankb = zlecs;
doinsert(wpaste, n);
yanke = zlecs;
accept-line accept-and-hold() {
if [[ $LASTWIDGET == bracketed-paste ]] &&
[[ $BUFFER[-1] == $'\n' ]]; then
zle .backward-delete-char
fi
zle .$WIDGET -- "$@"
}
zle -N accept-line
zle -N accept-and-hold
# Maybe do the same for the other accept-* widgets.
(( $+zle_highlight )) || zle_highlight=()
zle_highlight+=( paste:standout )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author