From 5659f442c09bf3e94a60887b998473af02590477 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 10 Jan 2002 11:00:05 +0000 Subject: allow manual pages to be shown separated by section with new separate-sections style (16426) --- Completion/Unix/Command/_man | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Completion/Unix/Command/_man') diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 3da15f9ba..44634369c 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -40,8 +40,28 @@ _man() { dirs=( $^manpath/(sman|man|cat)*/ ) awk='{print $1}' fi + if zstyle -t ":completion:${curcontext}:manuals" separate-sections; then + typeset -U sects + local ret=1 - _wanted manuals expl 'manual page' _man_pages + sects=( ${(o)${dirs##*(man|cat)}%/} ) + + (( $#sects )) || return 1 + + _tags manuals.${^sects} + while _tags; do + for sect in $sects; do + _requested manuals.$sect expl "manual page, section $sect" _man_pages && + ret=0 + done + (( ret )) || return 0 + done + + return 1 + else + sect= + _wanted manuals expl 'manual page' _man_pages + fi } _man_pages() { @@ -56,7 +76,7 @@ _man_pages() { matcher= fi - pages=( $dirs ) + pages=( ${(M)dirs:#*$sect/} ) compfiles -p pages '' '' "$matcher" '' dummy '*' pages=( ${^~pages}(N:t:r) ) -- cgit 1.4.1