Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: new and updated completions
- X-seq: zsh-workers 15588
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: PATCH: new and updated completions
- Date: Tue, 7 Aug 2001 12:36:37 +0200 (MET DST)
- In-reply-to: <3B6EA97A.CD6DCB4F@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Oliver Kiddle wrote:
> ...
>
> I've rewritten _dd to use _values. It highlights a bug/limitation of
> _values: it continues to offer options which have already been
> specified as if they were preceded by `*' in the spec. It wouldn't do
> this if, for example, the values were comma separated.
Yes, _values only ever works on a single word. The easiest fix for now
is to remove the specs already used in _dd itself. Dunno if this should
be put into a separate function or _values itself.
> I've also made a start of updating functions to make better use of the
> grouping of options with the same description. I've changed dict, GNU
> diff, GNU grep, loadkeys, GNU ls, GNU patch and wget. Things don't seem
> to work perfectly if I type grep --<tab> - the list is messed up but is
> fine after grep -<tab>.
Oops. Indeed -- because it matched the hyphens in the descriptions.
It also had problems with correction.
Bye
Sven
Index: Completion/Base/Completer/_approximate
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_approximate,v
retrieving revision 1.3
diff -u -r1.3 _approximate
--- Completion/Base/Completer/_approximate 2001/05/29 17:54:08 1.3
+++ Completion/Base/Completer/_approximate 2001/08/07 10:36:29
@@ -10,7 +10,7 @@
[[ _matcher_num -gt 1 || "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
-local _comp_correct _correct_expl comax cfgacc match
+local _comp_correct _correct_expl _correct_group comax cfgacc match
local oldcontext="${curcontext}" opm="$compstate[pattern_match]"
if [[ "$1" = -a* ]]; then
@@ -58,6 +58,9 @@
# else
PREFIX="(#a${_comp_correct})$PREFIX"
# fi
+
+ (( $_correct_group )) && _correct_expl[_correct_group]=${argv[(R)-*[JV]]}
+
builtin compadd "$_correct_expl[@]" "$@"
}
trap 'unfunction compadd' EXIT INT
@@ -72,6 +75,8 @@
_description corrections _correct_expl corrections \
"e:$_comp_correct" "o:$PREFIX$SUFFIX"
+
+ _correct_group="$_correct_expl[(I)-*[JV]]"
if _complete; then
if zstyle -t ":completion:${curcontext}:" insert-unambiguous &&
Index: Completion/Base/Utility/_describe
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_describe,v
retrieving revision 1.8
diff -u -r1.8 _describe
--- Completion/Base/Utility/_describe 2001/07/27 12:56:57 1.8
+++ Completion/Base/Utility/_describe 2001/08/07 10:36:29
@@ -78,9 +78,13 @@
fi
if [[ -n $_mats ]]; then
- compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -O $_strs -D $_mats -s $_strs
+ compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \
+ "${(@M)${(@P)_strs}##([^:\\]|\\?)##}"
+ compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_mats - \
+ "${(@M)${(@P)_strs}##([^:\\]|\\?)##}"
else
- compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -O $_strs -a $_strs
+ compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \
+ "${(@M)${(@P)_strs}##([^:\\]|\\?)##}"
fi
done
set - "$_argv[@]"
Index: Completion/Unix/Command/_dd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_dd,v
retrieving revision 1.2
diff -u -r1.2 _dd
--- Completion/Unix/Command/_dd 2001/08/06 14:42:04 1.2
+++ Completion/Unix/Command/_dd 2001/08/07 10:36:29
@@ -1,14 +1,22 @@
#compdef dd
-_values -S '=' 'option' \
- 'if[specify input file]:input file:_tilde_files' \
- 'of[specify output file]:output file:_tilde_files' \
- 'ibs[input block size]:block size (bytes)' \
- 'obs[output block size]:block size (bytes)' \
- 'bs[block size]:block size (bytes)' \
- 'cbs[conversion buffer size]:buffer size (bytes)' \
- 'skip[input blocks initially skipped]:blocks' \
- 'seek[output blocks initially skipped]:blocks' \
- 'files[specify number of input files to copy and concatenate]:number of files' \
- 'count[number of input blocks to copy]:blocks' \
+local opts
+
+opts=(
+ 'if[specify input file]:input file:_tilde_files'
+ 'of[specify output file]:output file:_tilde_files'
+ 'ibs[input block size]:block size (bytes)'
+ 'obs[output block size]:block size (bytes)'
+ 'bs[block size]:block size (bytes)'
+ 'cbs[conversion buffer size]:buffer size (bytes)'
+ 'skip[input blocks initially skipped]:blocks'
+ 'seek[output blocks initially skipped]:blocks'
+ 'files[specify number of input files to copy and concatenate]:number of files'
+ 'count[number of input blocks to copy]:blocks'
'conv[specify conversions to apply]:conversion:_values -s , "conversion" ascii ebcdic ibm block unblock lcase ucase swab noerror sync'
+)
+
+[[ "$PREFIX$SUFFIX" != *\=* ]] &&
+ opts=( "${(@)opts:#(${(j:|:)~words[2,-1]%%\=*})\[*}" )
+
+_values -S '=' 'option' "$opts[@]"
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author