about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-06-12 01:53:37 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-06-12 01:53:37 +0000
commit69dbd4af07fc23138617057384caade1df3a6a75 (patch)
tree2d6c6d58e989853be8e1a3055f45c8a06c9b9a35 /Completion
parent2c718e9f126f7ff0d2f417b288669f988f6ba7e4 (diff)
downloadzsh-69dbd4af07fc23138617057384caade1df3a6a75.tar.gz
zsh-69dbd4af07fc23138617057384caade1df3a6a75.tar.xz
zsh-69dbd4af07fc23138617057384caade1df3a6a75.zip
Merge of users/10282 and workers/22237.
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_man21
1 files changed, 16 insertions, 5 deletions
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index 4b7669010..8f28d34eb 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -19,7 +19,7 @@ _man() {
   fi
 
   (( $#_manpath )) ||
-      _manpath=( /usr/man(-/) /(opt|usr)/(dt|share|X11R6|local)/(cat|)man(-/) )
+      _manpath=( /usr/man(-/) /(opt|usr)/(pkg|dt|share|X11R6|local)/(cat|)man(-/) )
 
   # `sman' is the SGML manual directory for Solaris 7.
   # 1M is system administrator commands on SVR4
@@ -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 "$@"