From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: bracket-paste-magic adds backslashes inside a quoted string if URL is pasted ("regression" compared to pre-5.1 url-quote-magic)
Date: Fri, 13 May 2016 14:19:32 +0200 [thread overview]
Message-ID: <20160513121932.GA11181@zira.vinc17.org> (raw)
In-Reply-To: <CAH+w=7YYkto7u1WNcfmTs30o1wVGF4VRwnKmJtFz=5K4iLLp5A@mail.gmail.com>
On 2016-05-13 04:06:45 -0700, Bart Schaefer wrote:
> The proponents of "bracketing" the paste event take the position that
> a paste is one indivisible action and should be handled as such.
> bracketed-paste is like self-insert except that "self" is the entire
> pasted text at once. Context is irrelevant. Further, treating the
> paste this way is expected to "protect" the user from any unexpected
> content such as control characters that might have side-effects, and
> also to make reverting the paste be a single "undo" step.
I see. BTW, bracketed-paste-magic breaks the "undo": it clears
the whole line.
> This is in direct conflict with special handling of URLs (or any other
> kind of possibly-context-dependent action) where, by definition, there
> are side-effects from what would otherwise be ordinary input. Several
> choices have to be made in order to resolve this conflict.
> bracketed-paste-magic is designed to be a generalized paste handler
> that allows the user to specify what happens for each of those
> choices. Consequently the default behavior is to minimally extend the
> plain un-magical bracketed-paste, and the more magic you want the more
> incantations you must utter.
>
> I apologize if the use of -magic as a suffix here is confusing. It
> was not intended to imply a close connection between
> bracketed-paste-magic and url-quote-magic; it's more that both are
> inspired by the "magic-space" built-in widget.
OK. Since the only effect of bracketed-paste-magic I was seeing
was the url-quote-magic one, I thought that this was the equivalent
of url-quote-magic, but with paste instead of keys entered with the
keyboard.
So, the behavior I expect *on the buffer* seems to be the one with
backward-extend-paste (except that undo and paste highlighting are
broken).
> > Do you mean that instead of the zstyle
> > line, bracketed-paste-url-magic would do the work?
>
> No, quite the opposite. bracketed-paste-url-magic was written because
> its author felt that bracketed-paste-magic is too generalized, but he
> went far the other way: Context already on the line is entirely
> ignored, and nothing happens unless the entire paste looks like a
> single complete URL.
Indeed, I've tried, and it works badly. The paste must be a single
complete URL and form a single argument.
> >> 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?
> >
> > I would say: the same behavior as url-quote-magic.
>
> Again, I'm asking what might be done in the general case of someone
> using bracketed-paste-magic but not necessarily using url-quote-magic.
IMHO, the behavior should be similar to the case where the user enters
(non-control) characters one by one instead of pasting them.
Now, even url-quote-magic seems incomplete: if I start to type:
echo $(echo http://foo
then a question mark, it is not quoted.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
next prev parent reply other threads:[~2016-05-13 12:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 20:53 Axel Beckert
2016-05-08 18:50 ` Bart Schaefer
2016-05-09 14:13 ` Vincent Lefevre
2016-05-09 15:41 ` Bart Schaefer
2016-05-10 8:58 ` Vincent Lefevre
2016-05-10 19:58 ` Bart Schaefer
2016-05-13 9:23 ` Vincent Lefevre
2016-05-13 11:06 ` Bart Schaefer
2016-05-13 12:19 ` Vincent Lefevre [this message]
2016-06-02 7:20 ` undo problems/crashes (was Re: bracket-paste-magic ...) Bart Schaefer
2016-05-13 22:20 ` bracket-paste-magic adds backslashes inside a quoted string if URL is pasted ("regression" compared to pre-5.1 url-quote-magic) Daniel Shahaf
2016-05-14 1:33 ` Mikael Magnusson
2016-05-14 3:00 ` Daniel Shahaf
2016-05-15 11:59 ` Bart Schaefer
2016-05-19 21:14 ` Daniel Shahaf
2016-06-02 7:06 ` zle hook conventions (was Re: bracket-paste-magic ...) Bart Schaefer
2016-06-03 20:40 ` Daniel Shahaf
2016-06-03 22:51 ` Bart Schaefer
2016-06-04 16:57 ` Daniel Shahaf
2016-06-10 17:36 ` Daniel Shahaf
2016-06-10 19:51 ` Bart Schaefer
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=20160513121932.GA11181@zira.vinc17.org \
--to=vincent@vinc17.net \
--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).