From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>,
<zsh-workers@sunsite.dk>
Subject: Re: _man igores global matchers
Date: Thu, 31 May 2001 15:46:43 +0000 [thread overview]
Message-ID: <1010531154643.ZM18373@candle.brasslantern.com> (raw)
In-Reply-To: <000301c0e9d6$19e4ebc0$21c9ca95@mow.siemens.ru>
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
next prev parent reply other threads:[~2001-05-31 15:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-29 12:05 Andrej Borsenkow
2001-05-29 12:18 ` Sven Wischnowsky
2001-05-31 13:32 ` Andrej Borsenkow
2001-05-31 15:24 ` Sven Wischnowsky
2001-05-31 15:46 ` Bart Schaefer [this message]
2001-05-31 17:20 ` Bart Schaefer
2001-06-01 11:40 ` Sven Wischnowsky
2001-06-01 11:49 ` Sven Wischnowsky
2001-06-01 12:15 ` Clint Adams
2001-06-01 13:57 ` Bart Schaefer
2001-06-01 14:20 ` Sven Wischnowsky
2001-06-01 15:46 ` Bart Schaefer
2001-06-06 9:37 ` PATCH: " Sven Wischnowsky
2001-06-01 15:56 ` Bart Schaefer
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=1010531154643.ZM18373@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=Andrej.Borsenkow@mow.siemens.ru \
--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).