From 25848c5aa728935f12cd97ed92412f319048fb87 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 3 Mar 2008 01:29:17 +0000 Subject: 24653, 24659: Completion/Unix/Type/_path_commands: use a helper function to call "whatis" portably, and use compadd -O to pre-filter matches before reading $_command_descriptions. --- ChangeLog | 6 ++++++ Completion/Unix/Type/_path_commands | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 477084ee8..c87accf0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-03-02 Barton E. Schaefer + + * 24653, 24659: Completion/Unix/Type/_path_commands: use a + helper function to call "whatis" portably, and use compadd -O + to pre-filter matches before reading $_command_descriptions. + 2008-03-02 Peter Stephenson * 24656: Src/builtin.c: fix cd overeagerness to find integers diff --git a/Completion/Unix/Type/_path_commands b/Completion/Unix/Type/_path_commands index 0a4e3d512..340a013c3 100644 --- a/Completion/Unix/Type/_path_commands +++ b/Completion/Unix/Type/_path_commands @@ -23,6 +23,17 @@ done return 1 } +_call_whatis() { + case "$(whatis --version)" in + (whatis from *) + local -A args + zparseopts -D -A args s: r: + apropos "${args[-r]:-"$@"}" | fgrep "($args[-s]" + ;; + (*) whatis "$@";; + esac +} + _path_commands() { local need_desc expl ret=1 @@ -38,7 +49,7 @@ if zstyle -t ":completion:${curcontext}:" extra-verbose; then if ( [[ -n $first ]] || _cache_invalid command-descriptions ) && \ ! _retrieve_cache command-descriptions; then local line - for line in "${(f)$(_call_program command-descriptions whatis -s 1 -r .\\\*\; whatis -s 6 -r .\\\* 2> /dev/null)}"; do + for line in "${(f)$(_call_program command-descriptions _call_whatis -s 1 -r .\\\*\; _call_whatis -s 6 -r .\\\* 2>/dev/null)}"; do [[ -n ${line:#(#b)([^ ]#) #\([^ ]#\)( #\[[^ ]#\]|)[ -]#(*)} ]] && continue; [[ -z $match[1] || -z $match[3] || -z ${${match[1]}:#*:*} ]] && continue; _command_descriptions[$match[1]]=$match[3] @@ -50,9 +61,10 @@ if zstyle -t ":completion:${curcontext}:" extra-verbose; then fi if [[ -n $need_desc ]]; then - typeset -a dcmds descs cmds + typeset -a dcmds descs cmds matches local desc cmd sep - for cmd in ${(k)commands}; do + compadd "$@" -O matches -k commands + for cmd in $matches; do desc=$_command_descriptions[$cmd] if [[ -z $desc ]]; then cmds+=$cmd -- cgit 1.4.1