Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Shift-Insert overwrites ZLE CUTBUFFER



On Wed, Oct 26, 2016 at 6:01 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Oct 26, 12:28am, lolilolicon wrote:
> } Subject: Re: Shift-Insert overwrites ZLE CUTBUFFER
> }
> } On Wed, Oct 26, 2016 at 12:12 AM, Bart Schaefer
> } <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } > There's currently no easy way to change the cutbuffer behavior without
> } > disabling the rest of the bracketed-paste behavior.
> }
> } That's a shame.
> } Is it technically difficult to do? Would there be an issue if zsh just
> } popped the killring automatically?
>
> What I mean is that it's not easy to do from shell code.  In the source
> code obviously the implementation is deliberately pushing the kill ring,
> so it wouldn't be technically difficult to *not* do so, but that would
> mean reversing an earlier design decision.

Actually if you pass a parameter name to the bracketed-paste widget,
it stuffs the pasted content in there and does literally nothing else.
So a simple wrapper widget that doesn't mess with the yank buffer
could look like this:

my-bracketed-paste () {
  local wantquote=${NUMERIC:-0}
  local content
  zle .$WIDGET -N content
  if (( $wantquote == 1 )); then
    content=${(q-)content}
  fi
  LBUFFER+=$content
}

Or if you don't care about quoting the input ever, just

my-bracketed-paste () {
  local content
  zle .$WIDGET -N content
  LBUFFER+=$content
}

(see also the bracketed-paste-url-magic function distributed with zsh)

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author