Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [patch] Add ldap completer
- X-seq: zsh-workers 43072
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [patch] Add ldap completer
- Date: Tue, 19 Jun 2018 22:21:48 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1529439712; bh=QZ9gX+T1NW36NkPhekbqShg4UacmEMva1kAliOLym+Q=; h=From:References:To:Subject:Date:From:Subject; b=EQns7R24CdR1T+1D+fi0X/F0o8U9W6y8+e/VEXLj1YTh1z5UmOQLkW2VF0Gg40uL1m9kHvWkZPDgStZkACI+wUtCozh66SOfLKZXq2ynoU8qrsnWPvNmvSOp+n6odKZ3z7aK0DQoVeU4syjd6wQ3mbCNkTStoc/O/Z85peaEq+42XgtTpZG27R23WiPw17qyW4mnEXQbFxcB6rH4l6On3wPHrUBZOaUGQ8IxAC8EYKoA9+g4R1rcxMEtEvyhGFdHr/C/3QuTBDurA/urAWm7+skoYMR5RfpIE/kOYrO4NYk1doLmJ7w4GKlscy42qUflPfzahMk97ONtPDMj/Lwa4A==
- In-reply-to: <20180619125722.GA33230@CptOrmolo.darkstar>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180619125722.GA33230@CptOrmolo.darkstar>
Matthew Martin wrote:
> For the protocol _describe, is -I correct? I don't grok the differences
> between the prefixes and suffixes. For host is -S '' correct for not
> adding a space after and should the completer avoid adding the space?
You should use -S.
The normal way would actually be to have:
compset -S ':*' || suf=( -S :// )
Then append $suf to _describe.
-S/-P are what you normally use for separators like : / , etc.
These work together with the suffix auto-removal. The completion
matching is aware of them and considers them for some purposes.
-s/-p suffixes/prefixes are included in matching control. So if you use, e.g:
compadd -M 'r:|/=* r:|=*' -p "head/" - tail
then h/t</tab> will complete to head/tail
This is behind things like _multi_parts. They are also quoted
automatically whereas for -P/-S you might need compquote so these are
sometimes used to take advantage of that.
-i/-I is akin to directly modifying IPREFIX and ISUFFIX. They tend
to be used when bypassing matching but can have other uses. Aside
from quoting, they don't behave exactly like a direct modification of
IPREFIX/ISUFFIX but that goes beyond my understanding.
> The ldapi protocol is not completed correctly because I don't know how
> to make _files replace / with %2f.
I don't think you can currently without redoing much of _files. You
could probably still get _path_files (with -S %2f) to do much of the
work.
The completion system does track layers of quoting following compset -q
but you can't give it custom forms as %2f would be.
> + # [protocol://]host[:port][/basedn[?[attribute,...][?[scope][?[filter]]]]]
> + if ! compset -P '*://'; then
> + tags=(protocol)
> + fi
> +
> + if ! compset -P '*/'; then
> + if compset -P '*:'; then
In general, where you have compset -P. compset -S is also applicable
when completing whatever falls to the left of the separator.
> + _tags $tags
> + while _tags; do
> + _requested protocol && _describe -t protocol protocol protocols -I ://
> + _requested host && _hosts -S ''
> + _requested port && _guard '|<1-65535>' port
_guard was created to solve a particular problem. A quick demonstration
of which is the following: _arguments '--long' ':number:'
--l<tab> now does not complete to --long because number is being
offered.
I tend to limit it's use to these situations. Even if I've typed some
letters, getting the "port" description can still be useful.
> + _requested basedn expl 'base DN'
> + _requested attribute expl attribute
> + _requested scope && _describe -t scope scope scopes
If the scope is followed by '?' and a filter, you might want a ? suffix
on this. Perhaps in auto-removable form. Or the default suffix could be
auto-removable.
> + _requested filter expl filter
> + done
The tags loop is not correct. You need to break out of the loop if
matches were added. _alternative would work here. $tags never contains
more than one value, however, so the easiest would just be to directly
generate matches in each place where you assign to $tags.
If you don't like adding && ret=0 everywhere, compare
compstate[nmatches] from the start and end of the function.
> + ':: :_guard "*=*" "filter"' \
Is this really doing what you want: offering filter only if there is an
equals sign in the current word?
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author