From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13231 invoked by alias); 14 Aug 2011 22:15:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16223 Received: (qmail 29731 invoked from network); 14 Aug 2011 22:15:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110814151453.ZM19551@torch.brasslantern.com> Date: Sun, 14 Aug 2011 15:14:53 -0700 In-reply-to: <20110814205936.GI20653@prunille.vinc17.org> Comments: In reply to Vincent Lefevre "command completion" (Aug 14, 10:59pm) References: <20110814205936.GI20653@prunille.vinc17.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: command completion MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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).