From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Istvan Sebestyen <istvan@chains.ch>
Cc: zsh-workers@sunsite.dk
Subject: Re: Completion for `sub-options'
Date: Mon, 21 Apr 2003 11:03:46 +0200 [thread overview]
Message-ID: <2506.1050915826@gmcs3.logica.co.uk> (raw)
In-Reply-To: <20030419163956.GA25361@chains.ch>
Istvan Sebestyen wrote:
>
> I began to write a zsh completion for a little httpd. I saw then, that
> it isn't as easy as i thought, because the program hasn't regular
> options, it has `sub-options', too. The example would be:
>
> zsh% program --errordoc 404=/var/www/foobar.html
>
> First it should make the completion for the error code, what is
> trivial to make (401, 404, etc...). The second thing, it should put a
> `=' after the error-code completion and then look for _files -g
> '*.(html|htm|php|etc...)'.
You need to use compset -P and compset -S to divide the word at the
equals sign:
local suf expl
if compset -P '*='; then
_wanted documents expl 'document' _files -g '*.(html|htm|php)'
else
compset -S '=*' || suf=( -S = )
_wanted values expl 'error number' compadd $suf 401 404 405
fi
compset -P and compset -S chop off a prefix or a suffix respectively
from being considered by the completion system. So if it successfully
removes an error number from the beginning of the current word it
completes documents. Otherwise it completes error numbers after being
sure to ignore anything after an equals sign.
You could actually use _values for this if you find this simpler:
_values 'error document' {401,404,405}':document:_files -g "*.(html|htm|php)"'
Though _values is meant for slightly different cases really.
If you're using _arguments to complete the --errordoc option, you may
need to utilise a separate function or a state
('--errordoc:error document:->errordoc') to do this (though you could
use the _values stuff after doubly quoting it).
Oliver
prev parent reply other threads:[~2003-04-22 12:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-19 16:39 Istvan Sebestyen
2003-04-21 9:03 ` Oliver Kiddle [this message]
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=2506.1050915826@gmcs3.logica.co.uk \
--to=okiddle@yahoo.co.uk \
--cc=istvan@chains.ch \
--cc=zsh-workers@sunsite.dk \
/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).