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 Feb 13,  2:38pm, Yuri D'Elia wrote:
} Subject: Re: widget special PREFIX variable and cursor position with compl
}
} I'm still refining the ability to highlight the first ambiguous
} character in a completion list

Ah, thank you, that context is helpful.

} > The first time you press TAB, if the result is ambiguous (in your
} > example, four possible results) a completion listing and the cursor
} > is moved to the first disambiguating location.  At this point you
} 
} Yes, at this point I'm shown the completion list for the first
} ambiguous position, and I need to know the string up to the cursor
} location (not the entire argument), in order to match the ambiguous
} character in the list.

You want $compstate[unambiguous] and $compstate[unambiguous_cursor],
but you can't examine them until after the rest of completion is done
with its work -- perhaps by poking something into the $comppostfuncs
array (see the _all_matches completer for an example).

The string slice

   ${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}]}

should be the common prefix of all the entries in the listing but NOT
including any common characters that are SHOWN in the listing.  If you
want more details, ${(s/:/)compstate[unambiguous_positions]} gives
the offsets into $compstate[unambiguous] that divide it into segments
that would be kept unchanged when updating the command line.



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