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

Re: git-subtree completions



Jordan Klassen wrote:
> How do I fix my `THIS_IS_A_HACK` issue?

Use -A "-*" and change this line:
    '*:: :->option-or-argument' && ret=0
to:
    '*::: := ->option-or-argument' && ret=0

> And code review in general.

Otherwise, it looks good. I'd suggest using _default instead of _nothing
for an unknown subcommand. _nothing might be more accurate at the moment
but falling back to default completion is better if a new subcommand is
added to git-subtree and the completion isn't updated. I'm aware that
the same comment could apply elsewhere in _git.

The descriptions for subcommands also could do with adjusting.
References to things like <commit> and <repository> make less sense in
the absense of the rest of the help information these have been copied
from.

Coming back to the THIS_IS_A_HACK issue, I think there is arguably a bug
in _arguments. The documentation states that with two
colons, "the words special array and the CURRENT special parameter are
modified to refer only to the normal arguments". I would expect the
command to be a "normal argument" in this context but -P coming after it
appears to affect this.
  For: git subtree add <tab> we get words=( add '' ) CURRENT=2
  For: git subtree add -P <tab> we get words=( '' ) CURRENT=1
_arguments in the option-or-argument state needs
words=( anything '' ) CURRENT=2
Arguably, the -P is covered by the *: action and should be included too.

The relevant code for this is the following two lines in computil.c:
    if ((restr = (arg->type == CAA_RARGS)))
	      restrict_range(ca_laststate.optbeg, ca_laststate.argend);

restrict_range appears to restrict the range based on a start and end
index so is not equipped to remove options interspersed with normal
arguments. So my question for -workers folks is how do we make sense of
struct castate to correct this? I think we need something like
ca_laststate.args along with compwords from ca_laststate.argbeg onwards.

Oliver



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