From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16496 invoked from network); 2 Aug 2006 22:17:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 2 Aug 2006 22:17:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 16499 invoked from network); 2 Aug 2006 22:17:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 2 Aug 2006 22:17:36 -0000 Received: (qmail 23361 invoked by alias); 2 Aug 2006 22:17:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22579 Received: (qmail 23350 invoked from network); 2 Aug 2006 22:17:31 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 2 Aug 2006 22:17:31 -0000 Received: (qmail 16263 invoked from network); 2 Aug 2006 22:17:31 -0000 Received: from mta09-winn.ispmail.ntl.com (HELO mtaout03-winn.ispmail.ntl.com) (81.103.221.49) by a.mx.sunsite.dk with SMTP; 2 Aug 2006 22:17:29 -0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com with ESMTP id <20060802221728.HYDB1865.mtaout03-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Wed, 2 Aug 2006 23:17:28 +0100 Received: from pwslaptop.csr.com ([81.107.41.155]) by aamtaout02-winn.ispmail.ntl.com with ESMTP id <20060802221728.FGQW23938.aamtaout02-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Wed, 2 Aug 2006 23:17:28 +0100 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.7/8.13.7) with ESMTP id k72MHOLG009320 for ; Wed, 2 Aug 2006 23:17:25 +0100 Message-Id: <200608022217.k72MHOLG009320@pwslaptop.csr.com> From: Peter Stephenson To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: find .pod files for perldoc better Date: Wed, 02 Aug 2006 23:17:24 +0100 This enhances completion for perldoc so that it locates .pod files in the include path. Currently only .pm files are searched for. However, followers of Perl 6 will note files with names like Perl6/Overview.pod are appearing, and perldoc will locate them. Passing arguments to completion functions is unnecessarily difficult; as I noted in _perforce: # Hack: if there is a job view, it is at the end. # This is nasty, it's really unnecessarily difficult to # pass arguments within completion functions... I think, therefore, the way I've done it here is the most likely to work. Index: Completion/Unix/Command/_perldoc =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_perldoc,v retrieving revision 1.4 diff -u -r1.4 _perldoc --- Completion/Unix/Command/_perldoc 8 Jun 2005 12:45:35 -0000 1.4 +++ Completion/Unix/Command/_perldoc 2 Aug 2006 22:13:31 -0000 @@ -49,7 +49,7 @@ _files -g "*.(pod|pm)(-.)" && ret=0 else _alternative \ - 'modules:module: _perl_modules' \ + 'modules:module: _perl_modules -tP' \ 'pods:base pod: _perl_basepods' \ 'files:module or .pod file:_files -g "*.(pod|pm)(-.)"' && ret=0 fi Index: Completion/Unix/Type/_perl_modules =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_perl_modules,v retrieving revision 1.4 diff -u -r1.4 _perl_modules --- Completion/Unix/Type/_perl_modules 8 Jun 2005 12:45:36 -0000 1.4 +++ Completion/Unix/Type/_perl_modules 2 Aug 2006 22:13:31 -0000 @@ -6,7 +6,12 @@ # # Calculate all installed Perl modules. The result is cached # for future use. -# +# +# Options: +# +# -t[types]: indicate file types; currently the only one is -tP, +# to include .pod files as well as modules. +# # Available styles: # # * try-to-use-pminst @@ -20,22 +25,28 @@ _perl_modules () { # Set a sensible default caching policy. This has to be done inside # this function otherwise we wouldn't know the context for the style. - local update_policy + local update_policy sufpat=".pm" with_pod zstyle -s ":completion:${curcontext}:" cache-policy update_policy if [[ -z "$update_policy" ]]; then zstyle ":completion:${curcontext}:" cache-policy \ _perl_modules_caching_policy fi + if [[ $argv[-1] = -tP ]]; then + argv=("${(@)argv[1,-2]}") + sufpat="(.pm|.pod)" + with_pod=_with_pod + fi + local perl=${words[1]%doc} perl_modules if whence $perl >/dev/null; then - perl_modules=_${${perl//[^[:alnum:]]/_}#_}_modules + perl_modules=_${${perl//[^[:alnum:]]/_}#_}_modules$with_pod elif (( ${+commands[perl]} )); then perl=perl - perl_modules=_perl_modules + perl_modules=_perl_modules$with_pod else perl= - perl_modules=_unknown_perl_modules + perl_modules=_unknown_perl_modules$with_pod fi if ( [[ ${(P)+perl_modules} -eq 0 ]] || _cache_invalid $perl_modules ) && @@ -68,7 +79,7 @@ # Find all modules if [[ -d $libdir && -x $libdir ]]; then - new_pms=( $libdir/{[A-Z]*/***/,}*.pm~*blib* ) + new_pms=( $libdir/{[A-Z]*/***/,}*${~sufpat}~*blib* ) new_pms=( "${(@)new_pms##$libdir/##}" ) fi -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/