about summary refs log tree commit diff
path: root/Completion/Unix/Command/_man
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2006-06-09 19:55:48 +0000
committerClint Adams <clint@users.sourceforge.net>2006-06-09 19:55:48 +0000
commitef570806aac01bf1a487d9dbe7c10daaeae51613 (patch)
treec63fc16922b74469c225c7bd0c9578903936f268 /Completion/Unix/Command/_man
parentefd5cec449d254cc4e38243084feb796b57ed8d4 (diff)
downloadzsh-ef570806aac01bf1a487d9dbe7c10daaeae51613.tar.gz
zsh-ef570806aac01bf1a487d9dbe7c10daaeae51613.tar.xz
zsh-ef570806aac01bf1a487d9dbe7c10daaeae51613.zip
users/10282: complete associated sections with man page names.
Diffstat (limited to 'Completion/Unix/Command/_man')
-rw-r--r--Completion/Unix/Command/_man19
1 files changed, 15 insertions, 4 deletions
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index a75c1281c..8f28d34eb 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -28,7 +28,7 @@ _man() {
 
   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 @@ _man() {
     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() {
 }
 
 _man_pages() {
-  local matcher pages dummy
+  local matcher pages dummy sopt
 
   zparseopts -E M+:=matcher
 
@@ -90,7 +94,14 @@ _man_pages() {
   # 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 "$@"