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

Re: command completion



On Aug 14, 10:59pm, Vincent Lefevre wrote:
}
} I asked a question several years ago about command/function/etc.
} completion, but never had an answer. I'd like command completion
} to be preferred over directory completion.
} 
} % mkdir ~/blah-hdir
} % cdpath=(. ~)
} % setopt AUTO_CD
} % blah[TAB]
} 
} then both blah-cmd and blah-hdir/ are proposed. I don't see why
} blah-hdir/ should be regarded as a command.

This is because the _autocd completer in the zsh distribution has
explictly inserted itself as a completion function for the context
named -command-, via its #compdef line.

This is further complicated by what may be an inaccuracy in the zsh
manual description of the tag-order style.  It says:

     The values for the style are sets of space-separated lists of tags.
     The tags in each value will be tried at the same time; if no match
     is found, the next value is used. [...]
     [...example elided...]  Remaining tags will be
     tried if no completions are found.

What it really means, though, is that remaining tags (even those not
explicitly listed in the tag-order style) are tried if no UNAMBIGUOUS
completion is found.  That last sentence really belongs before the
example, and should be clarified.

The doc then goes on:

     In addition to tag names, each string in the value may take one of
     the following forms:

    -
          If any value consists of only a hyphen, then _only_ the tags
          specified in the other values are generated.  Normally all
          tags not explicitly selected are tried last if the specified
          tags fail to generate any matches.  This means that a single
          value consisting only of a single hyphen turns off completion.

Here we have the key.  In order to stop "remaining tags" from being tried,
the value "-" must appear somewhere in the completion style.  So your
problem is solved by:

    zstyle ':completion:*:complete:-command-:*' tag-order 'commands' -

(note trailing dash).



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