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

Re: bracket-paste-magic adds backslashes inside a quoted string if URL is pasted ("regression" compared to pre-5.1 url-quote-magic)

On May 10, 10:58am, Vincent Lefevre wrote:
} > We had quite a bit of discussion on related topics when bracketed-paste
} > was added.  The general idea is that a paste is treated as a unit, and
} > the default behavior of bracketed-paste-magic is to restrict its action
} > to remain "inside" that unit.
} I'm not sure what you call "unit"

A single keystroke.  A single widget event.  As if the entire paste, no
matter how large, is one indivisible object.

} but IMHO, the notion of unit
} should be different from the notion of argument.

"Argument" has no bearing here; these are units of user input, like,
say, pressing a function key; not units of shell syntax or command
line semantics.

Of course the reason bracketed-paste-magic exists is because sometimes
one might not want that.  The opposite end of the spectrum would be to
explode the paste completely into its individual keystrokes, but that's
no different than unsetting zle_bracketed_paste to turn it off.  So
with bracketed-paste-magic I took the route of keeping the pasted text
self-contained, like doing a recursive-edit or using the minibuffer,
but providing hooks to bring in surrounding context if desired.

bracketed-paste-url-magic takes a different approach, examining the
paste to see if it starts with a URI scheme and if so quoting the
whole thing, and otherwise not interfering with the default paste
behavior at all (so you get even less context sensitivity).

A third (so far unimplemented) approach would be to examine LBUFFER
for an unbalanced quote mark and treat the paste accordingly, but
what exactly does "accordingly" mean?  Escape any quotes of the same
type that are in the paste, or assume the user is intentionally
pasting the closing quote?

} Or perhaps there should be a function that does all the work for
} URL handling

There's more than one way to do it even now, so someone would have to
make a judgement call as to which way was "the" way in order to create
such a function.

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