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

Re: compsys argument-n not working



On Mar 18,  8:03am, Benjamin Andresen wrote:
}
} zstyle -e ':completion:*:cd:*' fake 'reply=TEST'
}
} this works, but will complete for both arguments to cd.

Really?  I can't get "cd" to complete anything for a second argument,
no matter what styles I've defined.  In fact it won't even tell me
a context with ^Xh at that point, which is probably a bug.

} zstyle -e ':completion:*:cd:*:argument-1:*' fake 'reply=TEST'
} 
} is supposed to work if I interprete the manual correctly.

     "... However, this is only the case if
      the command line is parsed with standard UNIX-style options and
      arguments, so many completions do not set this."

What that really means is that argument-N context is created only if
the completion is implemented in terms of the "comparguments" builtin,
which _cd is not.  And even then the value of N might not be a number,
but instead could be the string "rest" meaning that all remaining
arguments are to be treated the same.

(Even if _cd did support argument-N, the placement in the context
would be :completion:*:cd:argument-1: -- the context you used above
has too many colons after the command name field.)

The approach to use here is to explicitly check the argument position
within the style, rather than relying on the context string.

zstyle -e ':completion:*:cd:*' fake '(( CURRENT == 2 )) && reply=TEST'

However, as I said, for me that's not needed because cd won't complete
a second argument in any case.



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