--- _man.orig Fri May 19 09:55:05 2006 +++ _man Fri May 19 10:24:10 2006 @@ -28,7 +28,7 @@ local sect if [[ $OSTYPE = solaris* ]]; then - sect=$words[$words[(i)-s]+1] + sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]} elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then if [[ $sect != ${sect::="${sect//:/|}"} ]]; then sect="($sect)" @@ -44,7 +44,11 @@ dirs=( $^_manpath/(sman|man|cat)*/ ) awk='{print $1}' fi - if zstyle -t ":completion:${curcontext}:manuals" separate-sections; then + if [[ $OSTYPE = solaris* && ( $words[CURRENT] = -s* || $words[CURRENT-1] == -s ) ]]; then + [[ $words[CURRENT] = -s* ]] && compset -P '-s' + sects=( ${(o)${dirs##*(man|cat)}%/} ) + _wanted sections expl 'section' compadd -a sects + elif zstyle -t ":completion:${curcontext}:manuals" separate-sections; then typeset -U sects local ret=1 @@ -69,7 +73,7 @@ } _man_pages() { - local matcher pages dummy + local matcher pages dummy sopt zparseopts -E M+:=matcher @@ -90,7 +94,14 @@ # beginning with .<->: that handles problem cases like files called # `POSIX.1.5'. - compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))} + [[ $OSTYPE = solaris* ]] && sopt='-s ' + if ((CURRENT > 2)) || + ! zstyle -t ":completion:${curcontext}:manuals.$sect" insert-sections + then + compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))} + else + compadd "$@" -P "$sopt$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))} + fi } _man "$@"