Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: man pages as files, at last
- X-seq: zsh-workers 28468
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxx (Zsh hackers list)
- Subject: PATCH: man pages as files, at last
- Date: Fri, 03 Dec 2010 17:22:16 +0000
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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@xxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author