From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: ** matcher
Date: Wed, 25 Jul 2001 16:47:39 +0200 (MET DST) [thread overview]
Message-ID: <200107251447.QAA19199@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <000e01c1150e$9500fd40$21c9ca95@mow.siemens.ru>
Borsenkow Andrej wrote:
> With this style
>
> zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' '+r:|[._-]=** r:|=**'
>
> the following does not match
>
> bor@itsrm2% gdiff --i-lTAB
>
> but the following does
>
> bor@itsrm2% gdiff --i--lTAB
> bor@itsrm2% gdiff --ignore-blank-lines
> Completing option
> --ignore-blank-lines -- ignore lines that are all blank
> --ignore-matching-lines -- ignore lines that match regex
>
> Why?
Because that pattern-matching-before-calling-compdescribe has to come in
the loop (otherwise the matchers returned by _next_label won't be used).
And I found a buglet in bin_compadd() where using `--' before the
matches made any -M be ignored.
Bye
Sven
Index: Completion/Base/Utility/_describe
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_describe,v
retrieving revision 1.5
diff -u -r1.5 _describe
--- Completion/Base/Utility/_describe 2001/07/25 12:18:24 1.5
+++ Completion/Base/Utility/_describe 2001/07/25 14:46:12
@@ -5,6 +5,7 @@
local _opt _expl _tmpm _tmpd
local _type=values _descr _ret=1 _showd _nm _hide _args _grp _sep
local csl="$compstate[list]" csl2
+local _oargv _argv _new _strs _mats _opts _i _try=0
# Get the option.
@@ -25,55 +26,17 @@
zstyle -s ":completion:${curcontext}:$_type" list-separator _sep || _sep=--
-if zstyle -T ":completion:${curcontext}:$_type" list-grouped; then
- local _argv _new _strs _mats _opts _i=2
+_descr="$1"
+shift
- _argv=( "$@" )
+if [[ -n "$showd" ]] &&
+ zstyle -T ":completion:${curcontext}:$_type" list-grouped; then
+ _oargv=( "$@" )
_grp=(-g)
- _new=( "$1" )
- shift
-
- while (( $# )); do
-
- _strs="_a_$_i"
- eval local "_a_$_i;_a_$_i"'=( "${'$1'[@]}" )'
- _argv[_i]="_a_$_i"
- shift
- (( _i++ ))
-
- if [[ "$1" = (|-*) ]]; then
- _mats=
- else
- _matss="_a_$_i"
- eval local "_a_$_i;_a_$_i"'=( "${'$1'[@]}" )'
- _argv[_i]="_a_$_i"
- shift
- (( _i++ ))
- fi
-
- _opts=( "${(@)argv[1,(i)--]:#--}" )
- shift "$#_opts"
- (( _i += $#_opts ))
- if [[ $1 == -- ]]; then
- shift
- (( _i++ ))
- fi
-
- if [[ -n $_mats ]]; then
- compadd "$_opts[@]" -O $_strs -D $_mats -a $_strs
- else
- compadd "$_opts[@]" -O $_strs -a $_strs
- fi
- done
-
- set - "$_argv[@]"
else
_grp=()
fi
-_descr="$1"
-shift
-
[[ "$_type" = options ]] &&
zstyle -t ":completion:${curcontext}:options" prefix-hidden &&
_hide="${(M)PREFIX##(--|[-+])}"
@@ -81,6 +44,47 @@
_tags "$_type"
while _tags; do
while _next_label "$_type" _expl "$_descr"; do
+
+ if (( $#_grp )); then
+
+ set -- "$_oargv[@]"
+ _argv=( "$_oargv[@]" )
+ _i=1
+ (( _try++ ))
+ while (( $# )); do
+
+ _strs="_a_$_try$_i"
+ eval local "_a_$_try$_i;_a_$_try$_i"'=( "${'$1'[@]}" )'
+ _argv[_i]="_a_$_try$_i"
+ shift
+ (( _i++ ))
+
+ if [[ "$1" = (|-*) ]]; then
+ _mats=
+ else
+ _matss="_a_$_try$_i"
+ eval local "_a_$_try$_i;_a_$_try$_i"'=( "${'$1'[@]}" )'
+ _argv[_i]="_a_$_try$_i"
+ shift
+ (( _i++ ))
+ fi
+
+ _opts=( "${(@)argv[1,(i)--]:#--}" )
+ shift "$#_opts"
+ (( _i += $#_opts ))
+ if [[ $1 == -- ]]; then
+ shift
+ (( _i++ ))
+ fi
+
+ if [[ -n $_mats ]]; then
+ compadd "$_opts[@]" "$_expl[@]" -O $_strs -D $_mats -s $_strs
+ else
+ compadd "$_opts[@]" "$_expl[@]" -O $_strs -a $_strs
+ fi
+ done
+ set - "$_argv[@]"
+ fi
if [[ -n "$_showd" ]]; then
compdescribe -I "$_hide" "$_sep " _expl "$_grp[@]" "$@"
Index: Src/Zle/complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.17
diff -u -r1.17 complete.c
--- Src/Zle/complete.c 2001/07/25 08:52:34 1.17
+++ Src/Zle/complete.c 2001/07/25 14:46:14
@@ -616,13 +616,14 @@
}
}
}
+
+ ca_args:
+
if (mstr && (match = parse_cmatcher(name, mstr)) == pcm_err) {
zsfree(mstr);
return 1;
}
zsfree(mstr);
-
- ca_args:
if (!*argv && !dat.group && !dat.mesg &&
!(dat.aflags & (CAF_NOSORT|CAF_UNIQALL|CAF_UNIQCON|CAF_ALL)))
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
prev parent reply other threads:[~2001-07-25 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-25 13:34 Borsenkow Andrej
2001-07-25 14:47 ` Sven Wischnowsky [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=200107251447.QAA19199@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).