Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: widget special PREFIX variable and cursor position with complete_in_word
- X-seq: zsh-workers 32439
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Yuri D'Elia <wavexx@xxxxxxxxxx>
- Subject: PATCH: Re: widget special PREFIX variable and cursor position with complete_in_word
- Date: Thu, 27 Feb 2014 16:02:01 +0100
- Cc: Zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1393513322; bh=OJ/K6Va8gxBFOMQaXqtyjBgUevdWxy7aLkCwXG3VMtM=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Received:cc:In-reply-to:From:References:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=hs6WgSR5JO2FoMgjTjrA15a2nTPz6cMLJoTRaCKNfHi3UbT//V32wx8R5LLX8k3eji2T6kO15HNoh4QlgBbFYfPjIifyBMxrCelk7EEYnhDE+A9IdfxlMJ/lCaBVOeMAwCvXlRecYCovvi+rDXaXLiXdX33KrlIHORyIF8CVO8g=
- In-reply-to: <lek81q$tdt$2@ger.gmane.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <ldgnl5$fo8$1@ger.gmane.org> <140212214707.ZM25929@torch.brasslantern.com> <ldii13$jg7$1@ger.gmane.org> <140213092531.ZM26966@torch.brasslantern.com> <ldj21h$9dj$1@ger.gmane.org> <140213223438.ZM27375@torch.brasslantern.com> <13128.1392379014@thecus.kiddle.eu> <ldl3u8$302$1@ger.gmane.org> <13979.1392388765@thecus.kiddle.eu> <ldlddn$s7r$1@ger.gmane.org> <15748.1392413785@thecus.kiddle.eu> <ldsqrp$ndo$1@ger.gmane.org> <12657.1392655814@thecus.kiddle.eu> <ldtice$ntg$1@ger.gmane.org> <16810.1392737023@thecus.kiddle.eu> <le00gb$rfp$1@ger.gmane.org> <19322.1392746842@thecus.kiddle.eu> <le0d7h$al$1@ger.gmane.org> <12895.1393360892@thecus.kiddle.eu> <lek81q$tdt$2@ger.gmane.org>
Yuri D'Elia wrote:
> I would definitely like this as a general addition to the main completer.
>
> It just needs a customizable color for the match.
This patch adds a 'show-ambiguity' style. The value is the colour to
use.
One thing I've noticed is that the patterns specified with ZLS_COLORS
will also match descriptions. This can be annoying if the -- separator
(or whatever you configure the list-separator style to) matches for the
ambiguity. It is actually a nice feature if you include something like
'=(#b)(--) (*)==32=3' in list-colors. Given that there is syntax for
selecting matches by tag group, I wonder if something could be easily
added for the descriptions. I'm not sure what syntax would make sense.
Oliver
diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index 8dd781d..e881ea6 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -334,6 +334,14 @@ elif [[ nm -eq 0 && -z "$_comp_mesg" &&
compadd -x "$mesg"
fi
+if zstyle -s ":completion:${curcontext}:" show-ambiguity tmp; then
+ local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]}
+ local toquote='[=\(\)\|~^?*[\]#<>]'
+ [[ $tmp = (yes|true|on) ]] && tmp=4
+ [[ -n $prefix ]] &&
+ _comp_colors+=( "=(#i)${prefix[1,-2]//?/(}${prefix[1,-2]//(#m)?/${MATCH/$~toquote/\\$MATCH}|)}${prefix[-1]//(#m)$~toquote/\\$MATCH}(#b)(?|)*==$tmp" )
+fi
+
[[ "$_comp_force_list" = always ||
( "$_comp_force_list" = ?* && nm -ge _comp_force_list ) ]] &&
compstate[list]="${compstate[list]//messages} force"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index c304461..5a5e619 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2440,6 +2440,15 @@ completing words for the dict command. It allows words from different
dictionary databases to be added separately.
The default for this style is `false'.
)
+kindex(show-ambiguity, completion style)
+item(tt(show-ambiguity))(
+If the tt(zsh/complist) module is loaded, this style can be used to
+highlight the first ambiguous character in completion lists. The
+value is either a color indication such as those supported by the
+tt(list-colors) style or, with a value of tt(true), a default of
+underlining is selected. The highlighting is only applied if the
+completion display strings correspond to the actual matches.
+)
kindex(show-completer, completion style)
item(tt(show-completer))(
Tested whenever a new completer is tried. If it is true, the completion
Messages sorted by:
Reverse Date,
Date,
Thread,
Author