From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-users@zsh.org
Subject: Re: widget special PREFIX variable and cursor position with complete_in_word
Date: Tue, 25 Feb 2014 21:41:32 +0100 [thread overview]
Message-ID: <12895.1393360892@thecus.kiddle.eu> (raw)
In-Reply-To: <le0d7h$al$1@ger.gmane.org>
On 18 Feb, Yuri D'Elia wrote:
> It was failing for the following:
>
> touch 'file a'
> touch 'file b'
> ls file\ <TAB>
>
> which made me disregard it too quickly. Interestingly it fails due to
> the fact that $MATCH:q is translating ' ' to '\ ' (which should be
> literal in this context). Same for the quotes.
I'd really have expected superfluous quoting like that to be ignored.
Normally it is:
% b=xyz
% [[ $b = *\y* ]] && echo yup
yup
% a='\y'
% [[ $b = *$~a* ]] && echo yup
With your change it seems to work in single quotes but not for backslash
quotes.
I think it is perhaps better to explicitly quote characters that are
special in patterns rather than reverting the quoting for spaces and
quotes. I've included what I now have in full below to make it easier
for anyone following this.
Having used this for a little while now, I've found it is sometimes
vaguely useful. Is it worth adding to git? I'm inclined to think it
should be included in _main_complete as a zstyle option rather than as a
completer.
This is working for many things that need quoting like | and *. I can't
work out how to cope with an initial = mainly because I can't get the
pattern to match it.
A bug I found while looking at this is the following:
% zsh -f
% autoload -U compinit; compinit
% : ${PS\1<tab>
-> ${PPS1}
Oliver
#autoload
_show_ambiguity() {
(( $comppostfuncs[(I)_show_ambiguity_end] )) ||
comppostfuncs+=( _show_ambiguity_end )
return 1
}
_show_ambiguity_end() {
local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]}
local toquote='[\(\)\|~^?*[\]#]'
[[ -n $prefix ]] &&
ZLS_COLORS+=":=(#i)${prefix[1,-2]//?/(}${prefix[1,-2]//(#m)?/${MATCH/$~toquote/\\$MATCH}|)}${prefix[-1]//(#m)$~toquote/\\$MATCH}(#b)(?|)*==4"
}
_show_ambiguity "$@"
next prev parent reply other threads:[~2014-02-25 20:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 21:02 Yuri D'Elia
2014-02-13 5:47 ` Bart Schaefer
2014-02-13 13:38 ` Yuri D'Elia
2014-02-13 17:25 ` Bart Schaefer
2014-02-13 18:12 ` Yuri D'Elia
2014-02-14 6:34 ` Bart Schaefer
2014-02-14 11:56 ` Oliver Kiddle
2014-02-14 12:56 ` Yuri D'Elia
2014-02-14 14:39 ` Oliver Kiddle
2014-02-14 15:38 ` Yuri D'Elia
2014-02-14 21:36 ` Oliver Kiddle
2014-02-17 11:10 ` Yuri D'Elia
2014-02-17 13:28 ` Yuri D'Elia
2014-02-17 16:50 ` Oliver Kiddle
2014-02-17 17:54 ` Yuri D'Elia
2014-02-18 15:23 ` Oliver Kiddle
2014-02-18 16:07 ` Yuri D'Elia
2014-02-18 18:07 ` Oliver Kiddle
2014-02-18 19:45 ` Yuri D'Elia
2014-02-25 14:07 ` Jesper Nygårds
2014-02-25 14:33 ` Yuri D'Elia
2014-02-25 20:41 ` Oliver Kiddle [this message]
2014-02-26 8:15 ` Yuri D'Elia
2014-02-26 15:03 ` Yuri D'Elia
2014-02-26 8:16 ` Yuri D'Elia
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=12895.1393360892@thecus.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--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).