zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: command completion
Date: Sun, 14 Aug 2011 15:14:53 -0700	[thread overview]
Message-ID: <110814151453.ZM19551@torch.brasslantern.com> (raw)
In-Reply-To: <20110814205936.GI20653@prunille.vinc17.org>

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


  parent reply	other threads:[~2011-08-14 22:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-14 20:59 Vincent Lefevre
2011-08-14 21:09 ` Mikael Magnusson
2011-08-14 21:54   ` Vincent Lefevre
2011-08-14 22:14 ` Bart Schaefer [this message]
2011-08-14 23:07   ` Vincent Lefevre
2011-08-14 23:56     ` Bart Schaefer
2011-08-15  0:57       ` Vincent Lefevre
2011-08-15  4:13         ` Bart Schaefer
2011-08-15  9:18           ` Vincent Lefevre
2012-09-11 12:55 Command Completion Nick Cross
2012-09-11 14:15 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=110814151453.ZM19551@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).