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/13/2014 06:47 AM, Bart Schaefer wrote:
> I'm not understading what you mean by this.  Are you writing an actual
> completion widget, or are you writing a function that will be used as
> an argument to compdef, or are you writing a function whose name will
> be used as the value of a zstyle?  If the last, which zstyle?

I'm still refining the ability to highlight the first ambiguous character in a completion list, using the following styles:

hl_first_diff_color=4

hl-first-diff()
{
  reply=( "=(#b)${PREFIX:q}(?|)*==${hl_first_diff_color}" )
}

hl-first-diff-path()
{
  setopt local_options no_bad_pattern
  local expn="${PREFIX##*/}"
  reply=( "=(#b)${expn:q}(?|)*==${hl_first_diff_color}" )
}

zstyle -e ':completion:*' list-colors hl-first-diff
zstyle -e ':completion:*:all-files' list-colors hl-first-diff-path
zstyle -e ':completion:*:local-directories' list-colors hl-first diff-path
zstyle -e ':completion:*:directories' list-colors hl-first-diff-path
zstyle -e ':completion:*:commands' list-colors hl-first-diff-path

> 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.

> $CURSOR won't lie to you, but you'll find that it reflects what I
> described above, i.e., that the cursor returns to the end of the word
> before resuming the completion.

Unfortunately :(




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