From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14908 invoked by alias); 3 Dec 2010 17:22:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28468 Received: (qmail 14844 invoked from network); 3 Dec 2010 17:22:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) X-Authentication-Warning: pwslap01u.europe.root.pri: pws owned process doing -bs To: zsh-workers@zsh.org (Zsh hackers list) Subject: PATCH: man pages as files, at last X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.2.1 Date: Fri, 03 Dec 2010 17:22:16 +0000 Message-ID: <12523.1291396936@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 03 Dec 2010 17:22:19.0569 (UTC) FILETIME=[A3B6EA10:01CB930E] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.71.0.123 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 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