zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: man pages as files, at last
@ 2010-12-03 17:22 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2010-12-03 17:22 UTC (permalink / raw)
  To: Zsh hackers list

I've always been too cowardly to try to get _man to complete file names
instead of page references by default, since it's not universally
supported and I'm not entirely sure how to mix them as normal
alternatives.

This is the easy way out: if there's a "/" in the name you must be
looking for a file explicitly.  As it happens, I tend to use "./" in front
of manual pages I want to look at; further the man page for man here
says it treats words with a "/" specially, so this is good enough for
me.

I can't remember how many years it is since this was first requested.

It might want some _wanted stuff if anyone can remember what to put.

Index: Completion/Unix/Command/_man
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_man,v
retrieving revision 1.13
diff -p -u -r1.13 _man
--- Completion/Unix/Command/_man	21 Oct 2010 19:29:09 -0000	1.13
+++ Completion/Unix/Command/_man	3 Dec 2010 17:15:06 -0000
@@ -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
 }
 
-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-03 17:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-03 17:22 PATCH: man pages as files, at last Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).