mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-03 08:11:03 +02:00
Phil Pennock: 25854: fix Devel module completion for "perl -d:".
This commit is contained in:
parent
ac54a0f983
commit
b37952c37b
3 changed files with 40 additions and 4 deletions
|
@ -8,6 +8,10 @@
|
||||||
strings in the temporary variable tmp1 before joining them with
|
strings in the temporary variable tmp1 before joining them with
|
||||||
"|" to create an alternatives pattern.
|
"|" to create an alternatives pattern.
|
||||||
|
|
||||||
|
* Phil Pennock: 25854: Completion/Unix/Command/_perl,
|
||||||
|
Completion/Unix/Type/_perl_modules: fix module completion for
|
||||||
|
"perl -d:" (Devel modules).
|
||||||
|
|
||||||
2008-10-14 Clint Adams <clint@zsh.org>
|
2008-10-14 Clint Adams <clint@zsh.org>
|
||||||
|
|
||||||
* 25898: Src/module.c: avoid dereference of p after it is freed
|
* 25898: Src/module.c: avoid dereference of p after it is freed
|
||||||
|
|
|
@ -10,7 +10,7 @@ _perl () {
|
||||||
'-a[autosplit mode with -n or -p (splits $_ into @F)]' \
|
'-a[autosplit mode with -n or -p (splits $_ into @F)]' \
|
||||||
"-c[check syntax only (runs BEGIN and END blocks)]" \
|
"-c[check syntax only (runs BEGIN and END blocks)]" \
|
||||||
'-d[run scripts under debugger]' \
|
'-d[run scripts under debugger]' \
|
||||||
'-d\:-[run under control of a debugging/tracing module]:debugging/tracing module:_perl_modules' \
|
'-d\:-[run under control of a debugging/tracing module]:debugging/tracing module:_perl_modules --strip-prefix --perl-hierarchy=Devel' \
|
||||||
'-D-:set debugging flags (argument is a bit mask or flags): ' \
|
'-D-:set debugging flags (argument is a bit mask or flags): ' \
|
||||||
"*-e+:one line of script. Several -e's allowed. Omit [programfile]." \
|
"*-e+:one line of script. Several -e's allowed. Omit [programfile]." \
|
||||||
"-F-:split() pattern for autosplit (-a). The //'s are optional.: " \
|
"-F-:split() pattern for autosplit (-a). The //'s are optional.: " \
|
||||||
|
|
|
@ -12,6 +12,17 @@
|
||||||
# -t[types]: indicate file types; currently the only one is -tP,
|
# -t[types]: indicate file types; currently the only one is -tP,
|
||||||
# to include .pod files as well as modules.
|
# to include .pod files as well as modules.
|
||||||
#
|
#
|
||||||
|
# --perl-hierarchy=...: restrict results to modules under this hierarchy.
|
||||||
|
# Note that this does not affect the filesystem searching or caching,
|
||||||
|
# which always collect all results on the premise that anyone using
|
||||||
|
# completion of Perl modules will use the results in various contexts,
|
||||||
|
# so this only affects the results compadd'd.
|
||||||
|
#
|
||||||
|
# --strip-prefix: when using --perl-hierarchy, strip off that prefix when
|
||||||
|
# passing to compadd.
|
||||||
|
#
|
||||||
|
# All other options passed onto compadd.
|
||||||
|
#
|
||||||
# Available styles:
|
# Available styles:
|
||||||
#
|
#
|
||||||
# * try-to-use-pminst
|
# * try-to-use-pminst
|
||||||
|
@ -26,14 +37,25 @@ _perl_modules () {
|
||||||
# Set a sensible default caching policy. This has to be done inside
|
# Set a sensible default caching policy. This has to be done inside
|
||||||
# this function otherwise we wouldn't know the context for the style.
|
# this function otherwise we wouldn't know the context for the style.
|
||||||
local update_policy sufpat=".pm" with_pod
|
local update_policy sufpat=".pm" with_pod
|
||||||
|
local restrict_hierarchy=''
|
||||||
|
local -i strip_perl_prefix
|
||||||
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
||||||
if [[ -z "$update_policy" ]]; then
|
if [[ -z "$update_policy" ]]; then
|
||||||
zstyle ":completion:${curcontext}:" cache-policy \
|
zstyle ":completion:${curcontext}:" cache-policy \
|
||||||
_perl_modules_caching_policy
|
_perl_modules_caching_policy
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $argv[-1] = -tP ]]; then
|
if [[ -n $argv[(r)--perl-hierarchy=*] ]]; then
|
||||||
argv=("${(@)argv[1,-2]}")
|
restrict_hierarchy="${argv[(r)--perl-hierarchy=*]#--perl-hierarchy=}"
|
||||||
|
restrict_hierarchy="${restrict_hierarchy%::}::"
|
||||||
|
argv[(r)--perl-hierarchy=*]=()
|
||||||
|
fi
|
||||||
|
if [[ -n $argv[(r)--strip-prefix] ]]; then
|
||||||
|
strip_perl_prefix=1
|
||||||
|
argv[(r)--strip-prefix]=()
|
||||||
|
fi
|
||||||
|
if [[ -n $argv[(r)-tP] ]]; then
|
||||||
|
argv[(r)-tP]=()
|
||||||
sufpat="(.pm|.pod)"
|
sufpat="(.pm|.pod)"
|
||||||
with_pod=_with_pod
|
with_pod=_with_pod
|
||||||
fi
|
fi
|
||||||
|
@ -93,8 +115,18 @@ _perl_modules () {
|
||||||
_store_cache ${perl_modules#_} $perl_modules
|
_store_cache ${perl_modules#_} $perl_modules
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local expl
|
# Nothing above here should have filtered the results per-caller, so that
|
||||||
|
# the cache is always complete. From here on, it's safe to filter.
|
||||||
|
local -a perl_subset
|
||||||
|
if [[ -n $restrict_hierarchy ]]; then
|
||||||
|
perl_subset=( ${(PM)perl_modules:#${restrict_hierarchy}*} )
|
||||||
|
if (( strip_perl_prefix )); then
|
||||||
|
perl_subset=( ${perl_subset#$restrict_hierarchy} )
|
||||||
|
fi
|
||||||
|
perl_modules=perl_subset
|
||||||
|
fi
|
||||||
|
|
||||||
|
local expl
|
||||||
_wanted modules expl 'Perl module' compadd "$@" -a - $perl_modules
|
_wanted modules expl 'Perl module' compadd "$@" -a - $perl_modules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue