Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version;
        bh=6ipZbx4lncX52oef+cpsnyXIiaybALB4GVusi6027UA=;
        b=UQO0lDmPANXukP8vSRnYJwr72BU1F86uB3kvfVbxPymvqSrjCFwlUYvY0xaRqEC0d6
         5fHSY6ocRuysJEUSt9CqGETZXKeV6pm69hHQkYKDY2pDD4Nv1BJmgCFiFcFX2dvQPAaa
         Kfwq8sXqz1c2JQVcFc4Nfd46mSq4Ya3aAtJUj0d9sYB5aGVeTZBdbl6u/b1veIeSm+tR
         IGf31BRNJ/kRjrRYXS2bb471E5h1bs/8kbsA0Pebc75LIlLpdJBGkKdWMtSiOXopf3UC
         frcb3FpuIfzE3xJModRUswjSRO73ldByfylgrMjlbX7p46LTuEEUhU7Leds5aDjbs28t
         Q2yw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version;
        bh=6ipZbx4lncX52oef+cpsnyXIiaybALB4GVusi6027UA=;
        b=I/7HbTX81s8luLigcn+qUp8ElkcLRsE4ks2r+iuPIP/kY4RNcsp0lKkHggh9Y+ye3o
         PReIeYH2P/3THG1gaAYCvv16edt6epzStO7OWDN6k0QG9gfD2qXBqjlHvKaRh5Agn35t
         S/I828leGt4G7xx/8ByX0jvRvTV9ccQncZJ6Vxiq22vQpktRLoPXjNaks2ZHfbHdmJ5m
         ghUXOzVqsPR64XB4885xlrfImohlBkqIiB4O69o+qhWTiZwXwimpXk8uJj4LPhF73oyQ
         YjZU5Vgd08LuLrXoX0qMxL9axtKB1fzbmul/wtg+SUWLlcbkKXDwX2WPVwWBnNcVywJQ
         bJPA==
X-Gm-Message-State: AOPr4FUBwa2ndOr8WrGYntNe/cvn+dgT3ojvJ8WB8Zj+Fue6q5dh/2UDqtP3gXo+pJDGlA==
X-Received: by 10.98.41.70 with SMTP id p67mr61043958pfp.93.1462910277421;
        Tue, 10 May 2016 12:57:57 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160510125848.ZM1686@torch.brasslantern.com>
Date: Tue, 10 May 2016 12:58:48 -0700
In-Reply-To: <20160510085833.GA20332@cventin.lip.ens-lyon.fr>
Comments: In reply to Vincent Lefevre <vincent@vinc17.net>
        "Re: bracket-paste-magic adds backslashes inside a quoted string if URL is pasted ("regression" compared to pre-5.1 url-quote-magic)" (May 10, 10:58am)
References: <20160506205309.GY5029@sym.noone.org> 
	<160508115026.ZM10022@torch.brasslantern.com> 
	<20160509141306.GA18211@cventin.lip.ens-lyon.fr> 
	<160509084143.ZM13554@torch.brasslantern.com> 
	<20160510085833.GA20332@cventin.lip.ens-lyon.fr>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
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)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38466

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.

