zsh-users
 help / color / mirror / code / Atom feed
From: John <jmharres@gmail.com>
To: zsh-users@zsh.org
Subject: Re: ordering of file-patterns completions
Date: Wed, 06 Nov 2013 18:11:27 -0700	[thread overview]
Message-ID: <527AE8BF.6090706@gmail.com> (raw)
In-Reply-To: <131106080319.ZM19160@torch.brasslantern.com>

On 11/6/13, 9:03 AM, Bart Schaefer wrote:
> On Nov 6,  8:24am, John wrote:
> }
> } I have a tool which needs one file-patterns for the first file matched,
> } then the second and the rest should be of a different file-patterns.  I
> } don't see a way to do this.
>
> You probably want to write a custom completer with the _arguments utility
> function, and to leave file-patterns unspecified.
>
>
>      _foo() {
>        _arguments '1:The first file:_files -g "XXX.*"' \
> 		 '*:All other files:_files -g "*.${words[2]:x}"'
>      }
>
>      compdef _foo foo
>
> Here "1:" refers to the first argument (after skipping the command name
> and any option flags) whereas "$words[2]" refers to the second word
> of the entire command line (first word after the command name), so this
> doesn't quite generalize if there may be options (words starting with
> a hyphen) between the command name and the first file.  If that is the
> case, you'll need to do some pre-processing of $words before calling
> _arguments to determine which position to reference instead of [2].
Yeah, unfortunately I do.  I was using _arguments to process those, and 
then zstyle to deal with the files.  But I'm not quite understanding how 
to do what you're describing to pre-process them instead of using 
_arguments.
>
> (You can skip the "compdef" command if you put the body of _foo in a file
> named _foo in a directory referenced in your $fpath, and begin that file
> with the line "#compdef foo".)
>
> } Are there any examples of something similar to this around?
>
> There are lots of examples of using _arguments in the default set of
> completion functions.  If there is a standard tool that you know of that
> accepts arguments something like your custom one, try looking at the
> completion function for that.  You can usually find the name of that
> function by looking at ${_comps[command-name-here]}.

I searched through a number of them, but haven't found anything which 
has helped yet.

John


  reply	other threads:[~2013-11-07  1:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06 15:24 John
2013-11-06 16:03 ` Bart Schaefer
2013-11-07  1:11   ` John [this message]
2013-11-07  4:17     ` Bart Schaefer
2013-11-07  6:30       ` John
2013-11-07 15:06         ` 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=527AE8BF.6090706@gmail.com \
    --to=jmharres@gmail.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).