From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25074 invoked by alias); 6 Sep 2015 09:52:31 -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: 36429 Received: (qmail 7902 invoked from network); 6 Sep 2015 09:52:30 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=ham autolearn_force=no version=3.4.0 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= X-Sasl-enc: tELnjqxhtl0843o3R4E1j5tC5g66pWJofO49H7+hYy5d 1441533148 Date: Sun, 6 Sep 2015 09:52:24 +0000 From: Daniel Shahaf To: Carsten Hey Cc: zsh-workers@zsh.org Subject: Re: bracketed paste - chopping trailing newlines Message-ID: <20150906095224.GD1895@tarsus.local2> 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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150903235936.GH30848@bosko.stateful.de> User-Agent: Mutt/1.5.21 (2010-09-15) --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 is pressed; (b) zle_highlight is set; (c) newlines are removed only at . Cheers, Daniel --pWyiEgJYm5f9v55/ Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="paste.diff" 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; --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="paste.zshrc" 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 ) --pWyiEgJYm5f9v55/--