Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: widget special PREFIX variable and cursor position with complete_in_word



On 02/17/2014 12:10 PM, Yuri D'Elia wrote:
> On 02/14/2014 10:36 PM, Oliver Kiddle wrote:
>> That's odd. Perhaps something in your setup conflicts with it. It'd be
>> interesting to know what.
> 
> Ah yes, I was missing zsh/complist (setting the list-colors style was loading it automatically perhaps?)
> 
> I've refined a bit the _show_ambiguity_end function with what I already had:
> 
> _show_ambiguity_end()
> {
>   local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]:Q}
>   if [ -n $prefix ]
>   then
>     [ "$curtag" = "all-files" ] && prefix=${prefix##*/} 
>     ZLS_COLORS+=":=(#b)${prefix:q}(?|)*==4"
>   fi
> }

This is even more robust:

_show_ambiguity_end()
{
  local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]}
  if [ -n $prefix ]
  then
    [ ${compstate[quoting]} ] && prefix=${prefix[2,-1]} || prefix=${prefix:Q}
    [ "$curtag" = "all-files" ] && prefix=${prefix##*/}
    [ ${compstate[quoting]} ] || prefix=${prefix:q}
    ZLS_COLORS+=":=(#b)${prefix//?/?}(?|)*==4"
  fi
}

It actually works by matching the string length instead.
The quoting/unquoting is performed only to correctly strip the directory name.




Messages sorted by: Reverse Date, Date, Thread, Author