zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Carsten Hey <carsten@debian.org>
Cc: zsh-workers@zsh.org
Subject: Re: bracketed paste - chopping trailing newlines
Date: Sun, 6 Sep 2015 09:52:24 +0000	[thread overview]
Message-ID: <20150906095224.GD1895@tarsus.local2> (raw)
In-Reply-To: <20150903235936.GH30848@bosko.stateful.de>

[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]

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

[-- Attachment #2: paste.diff --]
[-- Type: text/x-patch, Size: 950 bytes --]

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;

[-- Attachment #3: paste.zshrc --]
[-- Type: text/plain, Size: 349 bytes --]

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 )


  reply	other threads:[~2015-09-06  9:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-29  1:24 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150906095224.GD1895@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=carsten@debian.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).