From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: Quoting the arguments to a function
Date: Sat, 17 Sep 2016 06:24:56 +0000 [thread overview]
Message-ID: <20160917062456.GA26155@fujitsu.shahaf.local2> (raw)
In-Reply-To: <160916100934.ZM11263__9881.101063411$1474045859$gmane$org@torch.brasslantern.com>
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.
next prev parent reply other threads:[~2016-09-17 6:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-15 21:41 zv
2016-09-15 22:17 ` Philippe Troin
2016-09-16 0:09 ` Lawrence Velázquez
2016-09-16 0:10 ` zv
2016-09-16 0:12 ` Lawrence Velázquez
2016-09-16 10:52 ` Vincent Lefevre
2016-09-16 17:09 ` Bart Schaefer
[not found] ` <160916100934.ZM11263__9881.101063411$1474045859$gmane$org@torch.brasslantern.com>
2016-09-17 6:24 ` Daniel Shahaf [this message]
2016-09-17 14:35 ` 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=20160917062456.GA26155@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-users@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).