From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17054 invoked by alias); 17 Sep 2016 06:26:01 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21934 Received: (qmail 18404 invoked from network); 17 Sep 2016 06:26:01 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.624061 secs); 17 Sep 2016 06:26:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=aaTR7ExjWawuy7YC 8KU3naNwFOM=; b=stkVHrmYkxIW+GoZ7B8ox/RAv87yirAI4dM7ts6to9X7Apg/ 8FDi+209s2rAt8pZHHH3+4scia+oIcLJTA3H5g35JHEMzsBGvBY1gZN2laszfj65 t7qwzNUVLSCq7Ni0CVs9/I+5YejKI1jr2gomknUH9jrfHnlqHSnN0VIN/YY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=aaTR7ExjWawuy7Y C8KU3naNwFOM=; b=eXv27dsLHkTqIP0Iek8wAX9Xt4jL71dud4URC4HbWW60M3T 8YAwe2EKXUsjfiAICXDwwo4fGsX98K9Rw2hTPdbsxfMFfztzbgHhqWPljKRio0GD NUGytL4eLUdnPECmke36jFiM00vEXVqCUfCeT0DmEBphtUPGYcqvEFANBTis= X-Sasl-enc: MQ65B4z2DYKhuoYkcKraCrY6Qt+D+JiVzWK53u9MGdjf 1474093553 Date: Sat, 17 Sep 2016 06:24:56 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: Quoting the arguments to a function Message-ID: <20160917062456.GA26155@fujitsu.shahaf.local2> References: <20160916105230.GB3491@cventin.lip.ens-lyon.fr> <160916100934.ZM11263__9881.101063411$1474045859$gmane$org@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <160916100934.ZM11263__9881.101063411$1474045859$gmane$org@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) Bart Schaefer wrote on Fri, Sep 16, 2016 at 10:09:34 -0700: > The nice thing about url-quote-magic is that it can make all of its > decisions based solely on examinination of the current word; if the > beginning of the word looks like "schema:" (for various values of > schema), then the rest of the word is subject to quoting. > > To do argument quoting based on the command context, one must either > accept the naive solution of examining only the first word on the > line, or do more detailed command-line analysis on the level of > what's done by the completion system. z-sy-h implements something like this to be able to highlight command positions throughout $PREBUFFER and $BUFFER. Specifically, z-sy-h's parser knows at any point what the last command word was and what are the $BUFFER start and end offsets of the current shell word. > It's also pretty easy to create a little widget to quote the current > word: > > quote-this-word() { zle select-in-blank-word; zle quote-region } > zle -N quote-this-word > bindkey \'\' quote-this-word > > (That is, if I type single-quote twice in fairly rapid succession, > quote the word the cursor is in or follows. Users of RC_QUOTES may > want to use two double-quotes or some other combination.) Even without RC_QUOTES, the binding «''» collides with the «'\''» sequence for embedding a literal single quote in a single-quoted string.