about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_man24
-rw-r--r--Completion/Zsh/Command/_zstyle1
2 files changed, 23 insertions, 2 deletions
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) )
 
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index ffd3c6dd4..48a39deed 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -100,6 +100,7 @@ styles=(
   remove-all-dups	 c:bool
   select-prompt          c:
   select-scroll          c:
+  separate-sections      c:bool
   single-ignored         c:single-ignored
   sort			 c:bool
   special-dirs		 c:sdirs