Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _man igores global matchers
- X-seq: zsh-workers 14621
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: "Andrej Borsenkow" <Andrej.Borsenkow@xxxxxxxxxxxxxx>, <zsh-workers@xxxxxxxxxx>
- Subject: Re: _man igores global matchers
- Date: Thu, 31 May 2001 15:46:43 +0000
- In-reply-to: <000301c0e9d6$19e4ebc0$21c9ca95@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <000301c0e9d6$19e4ebc0$21c9ca95@xxxxxxxxxxxxxx>
On May 31, 5:32pm, Andrej Borsenkow wrote:
}
} > Look at _man, you'll see things like:
} >
} > rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.*(:t) )
} >
} > I.e., it does its matching/filtering itself, before the completion code
} > has a chance to use any match specs.
} >
} > That's ugly. But caching could be pretty costly. Maybe we should make
} > it configurable, mentioning the problem with match specs?
I presume by "caching could be pretty costly" you mean something like the
patch below (which I will not commit without positive feedback). There's
not actually a cache there, but it does create some arrays with 5000 or so
elements.
} > Any other ideas, anyone?
}
} Is it possible just use _path_files?
No, because you're not completing the file names, you're completing just
some base part of the file names.
} Alternatively, it is nice having _path_files to support -O/-A flags.
} Was it not discussed somewhere?
It was discussed. The problem is that _path_files may call compadd more
than once to add different sets of completions, which is not presently
supported with -A/-O (each new call would overwrite the matches added by
a previous call).
This patch drops the filtering on man page name and instead slurps up all
the file basenames into the `rep' array, then passes that and the global
matcher spec to compadd to let it sort out the mess. If you have several
matchers this can get pretty slow, so it ought at least to cache `rep'
somewhere during the loop over the matchers; as it stands this is mostly
a proof of concept.
Index: Completion/Unix/Command/_man
===================================================================
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 _man
--- Completion/Unix/Command/_man 2001/04/09 20:14:09 1.1.1.1
+++ Completion/Unix/Command/_man 2001/05/31 15:20:19
@@ -6,16 +6,6 @@
_files || return 0
fi
-if [[ $compstate[pattern_match] != [^*] ]]; then
- # If a string other than *, we just want correction, so no `*'.
- star='*'
-fi
-
-if [[ -n $_comp_correct ]]; then
- # If this is set, we are correcting with this many approximations.
- approx="(#a${_comp_correct})"
-fi
-
if (( ! $#manpath )); then
local mp
mp=($(manpath 2>/dev/null))
@@ -32,10 +22,10 @@
mrd=(${^manpath/\%L/${LANG:-En_US.ASCII}}/mandb(N))
if [[ $words[2] = (<->*|1M|l|n) ]]; then
rep=(
- $manpath/(sman|man|cat)${words[2]}/${~approx}$PREFIX${~star}$SUFFIX.*(:t) )
+ $manpath/(sman|man|cat)${words[2]}/*.*(:t) )
(($#mrd)) && rep[$#rep+1]=($(awk "\$2 == \"$words[2]\" {print \$1}" $mrd))
else
- rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.*(:t) )
+ rep=( $manpath/(sman|man|cat)*/*.*(:t) )
(($#mrd)) && rep[$#rep+1]=($(awk '{print $1}' $mrd))
fi
@@ -43,5 +33,5 @@
# Remove any compression suffix, then remove the minimum possible string
# beginning with .<->: that handles problem cases like files called
# `POSIX.1.5'.
-(( $#rep )) && _wanted manuals expl 'manual page' \
- compadd - ${${rep%%.(bz2|z|gz|Z)}%.<->*}
+(( $#rep )) && rep=(${${rep%%.(bz2|z|gz|Z)}%.<->*}) &&
+ _wanted manuals expl 'manual page' compadd -M "$_matcher" -a rep
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author