summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Unix/Command/_man16
2 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 29a53c156..42f090136 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-03  Peter Stephenson  <pws@csr.com>
+
+	* 28468: Completion/Unix/Command/_man: if argument contains a
+	"/", complete file instead of manual page reference; prefer
+	files with man suffixes.
+
 2010-11-30  Peter Stephenson  <pws@csr.com>
 
 	* unposted: NEWS: add news about ${NAME:OFFSET} and took the
@@ -13872,5 +13878,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5132 $
+* $Revision: 1.5133 $
 *****************************************************
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index a3a4d4796..d1346f7cc 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -86,6 +86,18 @@ _man() {
 _man_pages() {
   local matcher pages dummy sopt
 
+  # What files corresponding to manual pages can end in.
+  local suf='.((?|<->*)(|.gz|.bz2|.Z|.lzma))'
+
+  if [[ $PREFIX$SUFFIX = */* ]]; then
+    # Easy way to test for versions of man that allow file names.
+    # This can't be a normal man page reference.
+    # Try to complete by glob first.
+    _path_files -g "*$suf" && return
+    _path_files
+    return
+  fi
+
   zparseopts -E M+:=matcher
 
   if (( $#matcher )); then
@@ -109,9 +121,9 @@ _man_pages() {
   if ((CURRENT > 2)) ||
       ! zstyle -t ":completion:${curcontext}:manuals.$sect" insert-sections
   then
-    compadd "$@" - ${pages%.((?|<->*)(|.gz|.bz2|.Z|.lzma))}
+    compadd "$@" - ${pages%$~suf}
   else
-    compadd "$@" -P "$sopt$sect " - ${pages%.((?|<->*)(|.gz|.bz2|.Z|.lzma))}
+    compadd "$@" -P "$sopt$sect " - ${pages%$~suf}
   fi
 }