zsh-users
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@berkom.de>
To: zsh-users@sunsite.dk
Subject: Re: How to get prefix with quotes in completion widgets?
Date: Tue, 16 Apr 2002 10:11:09 +0200	[thread overview]
Message-ID: <15547.56477.871277.502684@wischnow.berkom.de> (raw)
In-Reply-To: <39E723A47AE4D211A9E800A0C9DEB9F605B0E910@slon11308.csfp.co.uk>


Ebourne, Martin wrote:

> Hi,
> 
> How do I get access to a version of $PREFIX which includes the quotes within a completion widget?

Quoting in completion is (and always was) a *very* complicated matter,
because ultimately we just can't reproduce the original quoting in all
cases (e.g. we have f'oo<TAB> on the line and the completion code adds
foobar as a match -- and that's a simple example). So instead of
trying to be perfect the code tries to produce at least correct
results even if that means that some of the special quoting on the
line will be lost. Internally the code uses an unquoted form which is
turned into some kind of generically quoted form when listed or
inserted into the line. In most cases this means backslashes before
special characters. Then we added a bit of special treatment for
strings *starting* with single or double quotes to be able to preserve
at least these.

And these single or double quotes can be found in $compstate[quote]
and $compstate[all_quotes] (and $QIPREFIX, for a different purpose,
but usable anyway). However, this of course only works for correct
shell syntax on the line and in your example:

> ...
> 
> example insert ( 'foo', 'bar' )
>                         ^^^
>                         123

the whole `(...)' is reported to the completion code (from the lexer
invoked by it) as one string, with quotes inside it, not at the
beginning, so the completion code doesn't handle them specially.

So, to answer your question: in *this* case, with the probably not
intended interpretation of the command line which can't be changed in
the completion code, there is no way to find the quotes other than by
looking e.g. at $BUFFER and $CURSOR of $words[CURRENT] (the former two
are zle-parameters accessible read-only in the completion code).

But if the stuff you want to complete really looks different from what
you sent, there might be a way. And anyway I'd like to know in which
real-world case you need it, we might have other ideas to help you.

Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


  reply	other threads:[~2002-04-16  8:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-15 13:53 Ebourne, Martin
2002-04-16  8:11 ` Sven Wischnowsky [this message]
2002-04-16 10:26 Ebourne, Martin
2002-04-16 16:17 ` Bart Schaefer
2002-04-16 11:13 Ebourne, Martin
2002-04-18  8:33 Ebourne, Martin

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=15547.56477.871277.502684@wischnow.berkom.de \
    --to=wischnow@berkom.de \
    --cc=zsh-users@sunsite.dk \
    /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).