* Re: widget special PREFIX variable and cursor position with complete_in_word [not found] ` <lekvso$udp$1@ger.gmane.org> @ 2014-02-26 23:00 ` Oliver Kiddle 2014-02-27 11:20 ` Yuri D'Elia 0 siblings, 1 reply; 4+ messages in thread From: Oliver Kiddle @ 2014-02-26 23:00 UTC (permalink / raw) To: Yuri D'Elia; +Cc: Zsh workers Yuri D'Elia wrote: > On 02/26/2014 09:15 AM, Yuri D'Elia wrote: > > I also noticed so far that it fails for = like you said, and # too. # works fine in my testing. As do < and > but it is probably wise to quote them anyway. > It occurred to me that maybe = is incorrectly used literally for tokenization inside complist. > Could somebody look if the string is tokenized correctly? You're right. The complist code is splitting on =. With the following patch, the = can be matched. This allows a \= or plain = if it is inside (...). Any thoughts on if that's right? Oliver diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index b852ee9..5e5ba9f 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -383,12 +383,25 @@ getcoldef(char *s) } else if (*s == '=') { char *p = ++s, *t, *cols[MAX_POS]; int ncols = 0; + int nesting = 0; Patprog prog; /* This is for a pattern. */ - while (*s && *s != '=') - s++; + while (*s && (nesting || *s != '=')) { + switch (*s++) { + case '\\': + if (*s) + s++; + break; + case '(': + nesting++; + break; + case ')': + nesting--; + break; + } + } if (!*s) return s; *s++ = '\0'; ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: widget special PREFIX variable and cursor position with complete_in_word 2014-02-26 23:00 ` widget special PREFIX variable and cursor position with complete_in_word Oliver Kiddle @ 2014-02-27 11:20 ` Yuri D'Elia 0 siblings, 0 replies; 4+ messages in thread From: Yuri D'Elia @ 2014-02-27 11:20 UTC (permalink / raw) To: zsh-workers; +Cc: Zsh workers On 02/27/2014 12:00 AM, Oliver Kiddle wrote: > You're right. The complist code is splitting on =. With the following > patch, the = can be matched. This allows a \= or plain = if it is > inside (...). Any thoughts on if that's right? Looks (and works) ok for me. ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <lek81q$tdt$2@ger.gmane.org>]
* PATCH: Re: widget special PREFIX variable and cursor position with complete_in_word [not found] ` <lek81q$tdt$2@ger.gmane.org> @ 2014-02-27 15:02 ` Oliver Kiddle 2014-02-27 17:02 ` Yuri D'Elia 0 siblings, 1 reply; 4+ messages in thread From: Oliver Kiddle @ 2014-02-27 15:02 UTC (permalink / raw) To: Yuri D'Elia; +Cc: Zsh workers 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Re: widget special PREFIX variable and cursor position with complete_in_word 2014-02-27 15:02 ` PATCH: " Oliver Kiddle @ 2014-02-27 17:02 ` Yuri D'Elia 0 siblings, 0 replies; 4+ messages in thread From: Yuri D'Elia @ 2014-02-27 17:02 UTC (permalink / raw) To: zsh-workers On 02/27/2014 04:02 PM, Oliver Kiddle wrote: > 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. Shouldn't this include the complist fix? ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-27 17:04 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <ldgnl5$fo8$1@ger.gmane.org> [not found] ` <140212214707.ZM25929@torch.brasslantern.com> [not found] ` <ldii13$jg7$1@ger.gmane.org> [not found] ` <140213092531.ZM26966@torch.brasslantern.com> [not found] ` <ldj21h$9dj$1@ger.gmane.org> [not found] ` <140213223438.ZM27375@torch.brasslantern.com> [not found] ` <13128.1392379014@thecus.kiddle.eu> [not found] ` <ldl3u8$302$1@ger.gmane.org> [not found] ` <13979.1392388765@thecus.kiddle.eu> [not found] ` <ldlddn$s7r$1@ger.gmane.org> [not found] ` <15748.1392413785@thecus.kiddle.eu> [not found] ` <ldsqrp$ndo$1@ger.gmane.org> [not found] ` <12657.1392655814@thecus.kiddle.eu> [not found] ` <ldtice$ntg$1@ger.gmane.org> [not found] ` <16810.1392737023@thecus.kiddle.eu> [not found] ` <le00gb$rfp$1@ger.gmane.org> [not found] ` <19322.1392746842@thecus.kiddle.eu> [not found] ` <le0d7h$al$1@ger.gmane.org> [not found] ` <12895.1393360892@thecus.kiddle.eu> [not found] ` <lek7vc$tdt$1@ger.gmane.org> [not found] ` <lekvso$udp$1@ger.gmane.org> 2014-02-26 23:00 ` widget special PREFIX variable and cursor position with complete_in_word Oliver Kiddle 2014-02-27 11:20 ` Yuri D'Elia [not found] ` <lek81q$tdt$2@ger.gmane.org> 2014-02-27 15:02 ` PATCH: " Oliver Kiddle 2014-02-27 17:02 ` Yuri D'Elia
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).