zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: completion for perldoc
@ 1999-09-06 11:37 Sven Wischnowsky
  1999-09-06 18:18 ` Adam Spiers
  0 siblings, 1 reply; 12+ messages in thread
From: Sven Wischnowsky @ 1999-09-06 11:37 UTC (permalink / raw)
  To: zsh-workers


Adam Spiers wrote:

> How would you define a suite of command exactly?  I assumed it would
> be a function whose #compdef top line had many commands on it.  My
> _perl* stuff has a #compdef line for the pm* commands from pmtools,
> and a #compdef for perldoc, but I couldn't figure out how to squash
> them all into one file.

Well, you can always compare `$words[1]' in an `if' or `case' and then 
put the stuff from the #autoloaded functions in the same file and
execute it only if some parameter was set by the tests at the
beginning or something like that.

> I noticed Etc/Completion-style-guide soon after posting and realised
> the many problems with that _perl* :-(

Never mind. All this isn't fixed in stone yet and the `style-guide' is 
quite new.

Bye
 Sven

P.S.:   And, after all, we are all still learning what is possible with
        the function system.
P.P.S.: The function system started as an attempt to make the syntax
        easier to understand. And now we have a completion function
	that explains what it does by giving an equivalent `compctl' ;-)

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
  1999-09-06 11:37 PATCH: completion for perldoc Sven Wischnowsky
@ 1999-09-06 18:18 ` Adam Spiers
  1999-09-06 18:21   ` Adam Spiers
  0 siblings, 1 reply; 12+ messages in thread
From: Adam Spiers @ 1999-09-06 18:18 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> Adam Spiers wrote:
> > I noticed Etc/Completion-style-guide soon after posting and realised
> > the many problems with that _perl* :-(
> 
> Never mind. All this isn't fixed in stone yet and the `style-guide' is 
> quite new.

I've been uploading the style-guide and the _arguments documentation
to my brain, and improved versions are on the way.  _arguments is
great!  However a few things perplex me:

- Why can't you have multiple MESSAGE:ACTION pairs with the
  *:MESSAGE:ACTION form?  I'm having to resort to using an auxiliary
  function, e.g.:

_perldoc {
    _arguments -s \
        '-h:help:' \
        '(-q)-f:Perl built-in function:_perl_builtin_funcs' \
        '(-f)-q:Perl FAQ keyword:' \
        '*:Perl pod pages:_perl_pods'
}

_perl_pods {
    local nm="$compstate[nmatches]"

   _perl_modules
   _perl_basepods
   _path_files -J "Perl modules and .pods" -/ -g '*.(pod|pm)'

    [[ nm -ne compstate[nmatches] ]]
}


- Is it possible to do something like (-foo)*:MESSAGE:ACTION, i.e.
  specifying completion for normal args only if -foo hasn't been
  specified?

> P.P.S.: The function system started as an attempt to make the syntax
>         easier to understand. And now we have a completion function
> 	that explains what it does by giving an equivalent `compctl' ;-)

<rofl>  I hadn't thought of that :-D


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
  1999-09-06 18:18 ` Adam Spiers
@ 1999-09-06 18:21   ` Adam Spiers
  1999-09-07  8:57     ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Adam Spiers @ 1999-09-06 18:21 UTC (permalink / raw)
  To: zsh-workers

Adam Spiers (adam@thelonious.new.ox.ac.uk) wrote:
> _perldoc {
>     _arguments -s \
>         '-h:help:' \
>         '(-q)-f:Perl built-in function:_perl_builtin_funcs' \
>         '(-f)-q:Perl FAQ keyword:' \
>         '*:Perl pod pages:_perl_pods'
> }
> 
> _perl_pods {
>     local nm="$compstate[nmatches]"
> 
>    _perl_modules
>    _perl_basepods
>    _path_files -J "Perl modules and .pods" -/ -g '*.(pod|pm)'
> 
>     [[ nm -ne compstate[nmatches] ]]
> }

I forgot to say: this kills zsh :-(

Core was generated by `/usr/src/redhat/BUILD/zsh-3.1.6/Src/zsh'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libnsl.so.1...done.
Reading symbols from /lib/libtermcap.so.2...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from /lib/libnss_files.so.2...done.
Reading symbols from /usr/lib/zsh/3.1.6-pws-3/comp1.so...done.
Reading symbols from /usr/lib/zsh/3.1.6-pws-3/zle.so...done.
Reading symbols from /usr/lib/zsh/3.1.6-pws-3/compctl.so...done.
Reading symbols from /usr/lib/zsh/3.1.6-pws-3/complist.so...done.
#0  0x805ae09 in closemn ()
(gdb) bt
#0  0x805ae09 in closemn ()
#1  0x805c8ad in execcmd ()
#2  0x805aa38 in execpline2 ()
#3  0x805a2bc in execpline ()
#4  0x8059ec7 in execlist ()
#5  0x805e853 in runshfunc ()
#6  0x4016d557 in comp_setunset ()
#7  0x805e803 in runshfunc ()
#8  0x805e685 in doshfunc ()
#9  0x805e348 in execshfunc ()
#10 0x805cb3c in execcmd ()
#11 0x805aa38 in execpline2 ()
#12 0x805a2bc in execpline ()
#13 0x8059ec7 in execlist ()
#14 0x805e853 in runshfunc ()
#15 0x4016d557 in comp_setunset ()
#16 0x805e803 in runshfunc ()
#17 0x805e685 in doshfunc ()
#18 0x805e348 in execshfunc ()
#19 0x805cb3c in execcmd ()
#20 0x805aa38 in execpline2 ()
#21 0x805a2bc in execpline ()
#22 0x8059ec7 in execlist ()
#23 0x805e853 in runshfunc ()
#24 0x4016d557 in comp_setunset ()
#25 0x805e803 in runshfunc ()
#26 0x805e685 in doshfunc ()
#27 0x805e348 in execshfunc ()
#28 0x805cb3c in execcmd ()
#29 0x805aa38 in execpline2 ()
#30 0x805a2bc in execpline ()
#31 0x8059ec7 in execlist ()
#32 0x805e853 in runshfunc ()
#33 0x4016d557 in comp_setunset ()
#34 0x805e803 in runshfunc ()
#35 0x805e685 in doshfunc ()
#36 0x805e348 in execshfunc ()
#37 0x805cb3c in execcmd ()
#38 0x805aa38 in execpline2 ()
#39 0x805a2bc in execpline ()
#40 0x8059ec7 in execlist ()
#41 0x805e853 in runshfunc ()
#42 0x4016d557 in comp_setunset ()
#43 0x805e803 in runshfunc ()
#44 0x805e685 in doshfunc ()
#45 0x805e348 in execshfunc ()

etc. etc. (this goes on for a very long time!)

If you need any more debugging info, let me know.  (Why are all the
parameter lists empty?)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
  1999-09-06 18:21   ` Adam Spiers
@ 1999-09-07  8:57     ` Peter Stephenson
  1999-09-07  9:18       ` Adam Spiers
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 1999-09-07  8:57 UTC (permalink / raw)
  To: Zsh hackers list

Adam Spiers wrote:
> > _perldoc {
> > ...
> 
> I forgot to say: this kills zsh :-(

There's no () after _perldoc, so it thinks it's a function call, not a
definition.  You just generate hundreds of recursive calls to _perldoc
until the machine gets board of having enough space on the stack, or
something.

Also, since it's assumed in the completion functions that KSH_AUTOLOAD
isn't set, you need to have as the last line `_perldoc "$@"' to call
the function you've just defined.

The may be a bug here.  Has anyone the slightest idea why `_perldoc {'
is accepted as a complete command line with the argument "{"?

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56100 Pisa, Italy


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
  1999-09-07  8:57     ` Peter Stephenson
@ 1999-09-07  9:18       ` Adam Spiers
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Spiers @ 1999-09-07  9:18 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson (pws@ifh.de) wrote:
> Adam Spiers wrote:
> > > _perldoc {
> > > ...
> > 
> > I forgot to say: this kills zsh :-(
> 
> There's no () after _perldoc, so it thinks it's a function call, not a
> definition.  You just generate hundreds of recursive calls to _perldoc
> until the machine gets board of having enough space on the stack, or
> something.

Yes, I'm ashamed to say this was indeed the problem, and as usually
happens, I only realised it after I'd posted.

> Also, since it's assumed in the completion functions that KSH_AUTOLOAD
> isn't set, you need to have as the last line `_perldoc "$@"' to call
> the function you've just defined.

Ah!  So /that's/ why I was having to press TAB twice.  Thanks.

> The may be a bug here.  Has anyone the slightest idea why `_perldoc {'
> is accepted as a complete command line with the argument "{"?

Nope.  I've been bitten by that more than just this once though; I
always forget the () ...


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
  1999-09-07  8:32 Sven Wischnowsky
@ 1999-09-07  9:49 ` Adam Spiers
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Spiers @ 1999-09-07  9:49 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> Adam Spiers wrote:
> > - Why can't you have multiple MESSAGE:ACTION pairs with the
> >   *:MESSAGE:ACTION form?  I'm having to resort to using an auxiliary
> >   function, e.g.:
> 
> There three forms that allow you to specify completion for
> (non-option-) arguments:

[snip]

Sorry, badly phrased question.  I understood the three forms;
my question was, why can't the third form:

>    `*:mesg:action'
>      specify completion for `all other' arguments

look like this:

     `*:mesg1:action1:mesg2:action2:...'

?

So that instead of this (which now works!) ...

    _perldoc () {
        _arguments -s \
            '-h:help:' \
            '(-q)-f:Perl built-in function:_perl_builtin_funcs' \
            '(-f)-q:Perl FAQ keyword:' \
            '*:Perl pod pages:_perl_pods'
    }

    _perl_pods () {
        local nm="$compstate[nmatches]"

       _perl_modules
       _perl_basepods
       _path_files -J 'Perl modules and .pods' -/ -g '*.(pod|pm)'

        [[ nm -ne "$compstate[nmatches]" ]]
    }

I could do something like:

    _perldoc () {
        _arguments -s \
            '-h:help:' \
            '(-q)-f:Perl built-in function:_perl_builtin_funcs' \
            '(-f)-q:Perl FAQ keyword:' \
            '*:Perl modules:_perl_modules:Perl base pods:_perl_basepods:Perl modules and .pods:_path_files -/ -g \*.\(pod\|pm\)'
    }

> > - Is it possible to do something like (-foo)*:MESSAGE:ACTION, i.e.
> >   specifying completion for normal args only if -foo hasn't been
> >   specified?
> 
> There is no direct support for this. I'm not sure what you really want 
> to have, but I think (or: hope) you can do it with:
> 
>   `-foo:*:mesg1:action1' '*:mesg2:action2'
> 
>     which makes *all* arguments after the option `-foo' be completed
>     with `action1' (if that is empty, nothing will be completed, of
>     course), and if `-foo' is not given, the second specification will 
>     be used
> 
> This can then be used together with some trickery for `action1' to
> achieve almost everything. If that is not enough or too clumsy to use, 
> I'd like to see the real world example that made you wish for this.
> And then I'll think about ways to make this easier.

The example I'm thinking of is (surprise, surprise) perldoc.  The word
after -f is now correctly completed to Perl's built-in functions.
However, I want to prevent further completions if `-f print ' (say)
has been typed in, since `perldoc -f print Perl::Module' is
nonsensical to perldoc.

    `(-q)-f:built-in function:_perl_builtin_func:*:'

works, but

    `(-f)-q:FAQ keyword::*:'

gets confused by the empty ACTION.  I tried

    `(-f)-q:FAQ keyword:():*:'

but then it doesn't print `FAQ keyword'.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
@ 1999-09-07  9:02 Sven Wischnowsky
  0 siblings, 0 replies; 12+ messages in thread
From: Sven Wischnowsky @ 1999-09-07  9:02 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Adam Spiers wrote:
> > > _perldoc {
> > > ...
> > 
> > I forgot to say: this kills zsh :-(
> 
> There's no () after _perldoc, so it thinks it's a function call, not a
> definition.  You just generate hundreds of recursive calls to _perldoc
> until the machine gets board of having enough space on the stack, or
> something.

Ah, was that it? I thought he had just copied the bodies from
somewhere and added the `perldoc {' by hand.

So, just forget the end of my last message, please.

> The may be a bug here.  Has anyone the slightest idea why `_perldoc {'
> is accepted as a complete command line with the argument "{"?

Dunno, but `ksh' and `bash' behave in the same way.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
@ 1999-09-07  8:59 Sven Wischnowsky
  0 siblings, 0 replies; 12+ messages in thread
From: Sven Wischnowsky @ 1999-09-07  8:59 UTC (permalink / raw)
  To: zsh-workers


Adam Spiers wrote:

> Adam Spiers (adam@thelonious.new.ox.ac.uk) wrote:
> > _perldoc {
> >     _arguments -s \
> >         '-h:help:' \
> >         '(-q)-f:Perl built-in function:_perl_builtin_funcs' \
> >         '(-f)-q:Perl FAQ keyword:' \
> >         '*:Perl pod pages:_perl_pods'
> > }
> > 
> > _perl_pods {
> >     local nm="$compstate[nmatches]"
> > 
> >    _perl_modules
> >    _perl_basepods
> >    _path_files -J "Perl modules and .pods" -/ -g '*.(pod|pm)'
> > 
> >     [[ nm -ne compstate[nmatches] ]]
> > }
> 
> I forgot to say: this kills zsh :-(
>
> ...
> 
> If you need any more debugging info, let me know.  (Why are all the
> parameter lists empty?)

Yes I need more, namely the exact command line where you tried
completion. I've tested `perldoc' with completion after `-f', `-q',
and in a normal argument position and all this seems to work for me,
but I had to change `_perl_basepods' to use `whence -p basepod'
instead of `which ...' because I don't have `basepods'. I also had to
change `_perl_builtin_funcs' to use `command man ...' because I happen 
to have a function called `man'.

About the argument lists: did you really compile the beast with
debugging? (`-ggdb' in your Makefile, or at least `-g'?)

Otherwise the backtrace seems very fishy, because `comp_setunset'
doesn't call `runshfunc'.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
@ 1999-09-07  8:32 Sven Wischnowsky
  1999-09-07  9:49 ` Adam Spiers
  0 siblings, 1 reply; 12+ messages in thread
From: Sven Wischnowsky @ 1999-09-07  8:32 UTC (permalink / raw)
  To: zsh-workers


Adam Spiers wrote:

> Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> > Adam Spiers wrote:
> > > I noticed Etc/Completion-style-guide soon after posting and realised
> > > the many problems with that _perl* :-(
> > 
> > Never mind. All this isn't fixed in stone yet and the `style-guide' is 
> > quite new.
> 
> I've been uploading the style-guide and the _arguments documentation
> to my brain, and improved versions are on the way.  _arguments is
> great!  However a few things perplex me:
> 
> - Why can't you have multiple MESSAGE:ACTION pairs with the
>   *:MESSAGE:ACTION form?  I'm having to resort to using an auxiliary
>   function, e.g.:

There three forms that allow you to specify completion for
(non-option-) arguments:

  `num:mesg:action'
    specify completion for the num'th argument

  `:mesg:action'
    specify completion for the next argument (this is like the first
    one with `_argument' filling in the number automatically, for the
    cases where you just specify the completions for all arguments in
    the normal order one after another)

   `*:mesg:action'
     specify completion for `all other' arguments

These can be combined, of course:

  _arguments ':foo:(1 2)' '*:bar:(3 4)'

    completes `(1 2)' for the first argument and `(3 4)' for all other 
    arguments

  _arguments '2:foo:(1 2)' '*:bar:(3 4)'

    completes `(1 2)' for the *second* argument and `(3 4)' for all other 
    arguments


> - Is it possible to do something like (-foo)*:MESSAGE:ACTION, i.e.
>   specifying completion for normal args only if -foo hasn't been
>   specified?

There is no direct support for this. I'm not sure what you really want 
to have, but I think (or: hope) you can do it with:

  `-foo:*:mesg1:action1' '*:mesg2:action2'

    which makes *all* arguments after the option `-foo' be completed
    with `action1' (if that is empty, nothing will be completed, of
    course), and if `-foo' is not given, the second specification will 
    be used

This can then be used together with some trickery for `action1' to
achieve almost everything. If that is not enough or too clumsy to use, 
I'd like to see the real world example that made you wish for this.
And then I'll think about ways to make this easier.

Ok?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
  1999-09-06  9:28 Sven Wischnowsky
@ 1999-09-06 10:07 ` Adam Spiers
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Spiers @ 1999-09-06 10:07 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> 
> Adam Spiers wrote:
> 
> > Here's a completion system for perldoc.  It's my first stab at
> > completions with the new system, so be warned: you may need to change
> > some glaring mistakes.  If it's very wrong, let me know; OTOH if it's
> > OKish then maybe there's more where that came from.
> 
> Every attempt to write stuff for the new completion system is OKish.
> 
> > (Completion/User is the right place, right?)
> 
> Yes, but we somehow seem to have agreed (or `most of us...') to put
> everything for one command or suite of command into one function.

How would you define a suite of command exactly?  I assumed it would
be a function whose #compdef top line had many commands on it.  My
_perl* stuff has a #compdef line for the pm* commands from pmtools,
and a #compdef for perldoc, but I couldn't figure out how to squash
them all into one file.

> > Oh, and the zle -R bit doesn't work: it displays the text and then
> > immediately erases it.  No doubt this is some misunderstanding on my
> > part.
> 
> `zle -R' is intended for interactive functions (normal widgets). If
> you just want to display a message, use the function `_message'.
> 
> You may also want to have a look at `Etc/zsh-development-guide' and
> `Etc/Completion-style-guide' (the latter is not at all complete --
> I'll be thankful for every comment that helps improve it).

I noticed Etc/Completion-style-guide soon after posting and realised
the many problems with that _perl* :-(

I'll try to fix them and repost.

Finally, thanks Sven for such amazingly quick patches to the bugs I
reported.

Adam


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: completion for perldoc
@ 1999-09-06  9:28 Sven Wischnowsky
  1999-09-06 10:07 ` Adam Spiers
  0 siblings, 1 reply; 12+ messages in thread
From: Sven Wischnowsky @ 1999-09-06  9:28 UTC (permalink / raw)
  To: zsh-workers


Adam Spiers wrote:

> Here's a completion system for perldoc.  It's my first stab at
> completions with the new system, so be warned: you may need to change
> some glaring mistakes.  If it's very wrong, let me know; OTOH if it's
> OKish then maybe there's more where that came from.

Every attempt to write stuff for the new completion system is OKish.

> (Completion/User is the right place, right?)

Yes, but we somehow seem to have agreed (or `most of us...') to put
everything for one command or suite of command into one function.

> Oh, and the zle -R bit doesn't work: it displays the text and then
> immediately erases it.  No doubt this is some misunderstanding on my
> part.

`zle -R' is intended for interactive functions (normal widgets). If
you just want to display a message, use the function `_message'.

You may also want to have a look at `Etc/zsh-development-guide' and
`Etc/Completion-style-guide' (the latter is not at all complete --
I'll be thankful for every comment that helps improve it).

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread

* PATCH: completion for perldoc
@ 1999-09-05 21:38 Adam Spiers
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Spiers @ 1999-09-05 21:38 UTC (permalink / raw)
  To: zsh workers mailing list

Here's a completion system for perldoc.  It's my first stab at
completions with the new system, so be warned: you may need to change
some glaring mistakes.  If it's very wrong, let me know; OTOH if it's
OKish then maybe there's more where that came from.

(Completion/User is the right place, right?)

Oh, and the zle -R bit doesn't work: it displays the text and then
immediately erases it.  No doubt this is some misunderstanding on my
part.


diff -urN zsh-3.1.6-clean/Completion/User/_perl_basepods zsh-3.1.6-adam/Completion/User/_perl_basepods
--- zsh-3.1.6-clean/Completion/User/_perl_basepods	Thu Jan  1 01:00:00 1970
+++ zsh-3.1.6-adam/Completion/User/_perl_basepods	Sun Sep  5 22:24:50 1999
@@ -0,0 +1,30 @@
+#autoload
+#
+# _perl_basepods - zsh completion function
+#
+# Adam Spiers <adam@spiers.net>
+#
+# Calculate all installed Perl base pods (perlfunc, perlfaq etc.).
+# The result is cached for future use.
+#
+
+if [[ ${+_perl_basepods} -eq 0 ]]; then
+  typeset -agU _perl_basepods
+
+  if which basdepods >/dev/null; then
+    _perl_basepods=( ${$(basepods):t:r} )
+  else
+    local podpath
+    podpath=$(perl -MConfig -e 'print "$Config{installprivlib}/pod"')
+    if [[ ! -e $podpath/perl.pod ]]; then
+      echo "Couldn't find perl.pod from Config.pm; giving up."
+      return 1
+    else
+      cd $podpath
+      _perl_basepods=( *.pod(:r:t) )
+      cd $OLDPWD
+    fi
+  fi
+fi
+
+compadd - $_perl_basepods
diff -urN zsh-3.1.6-clean/Completion/User/_perl_builtin_funcs zsh-3.1.6-adam/Completion/User/_perl_builtin_funcs
--- zsh-3.1.6-clean/Completion/User/_perl_builtin_funcs	Thu Jan  1 01:00:00 1970
+++ zsh-3.1.6-adam/Completion/User/_perl_builtin_funcs	Sun Sep  5 22:24:50 1999
@@ -0,0 +1,29 @@
+#autoload
+#
+# _perl_builtin_funcs - zsh completion function
+#
+# Adam Spiers <adam@spiers.net>
+#
+# Calculate all built-in Perl functions.  The result is cached
+# for future use.
+#
+
+if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
+  typeset -agU _perl_builtin_funcs
+  local perlfunc
+
+  if perlfunc=`man -w perlfunc 2>&1`; then
+    _perl_builtin_funcs=( `perl -lne '
+                             $in_funcs++, next if /Alphabetical/;     \
+                             next unless $in_funcs;                   \
+                             if (/^\.Ip "(\w+)/) {                    \
+                               print $1 unless $func{$1}; $func{$1}++ \
+                             }' $perlfunc`
+               )
+  else
+    echo "Couldn't find perlfunc man page; giving up."
+    return 1
+  fi
+fi
+
+compadd - $_perl_builtin_funcs
diff -urN zsh-3.1.6-clean/Completion/User/_perl_modules zsh-3.1.6-adam/Completion/User/_perl_modules
--- zsh-3.1.6-clean/Completion/User/_perl_modules	Thu Jan  1 01:00:00 1970
+++ zsh-3.1.6-adam/Completion/User/_perl_modules	Sun Sep  5 22:24:50 1999
@@ -0,0 +1,47 @@
+#compdef pmpath pmvers pmdesc pmload pmexp pmeth pmls pmcat pman pmfunc podgrep podtoc podpath
+#
+#
+# _perl_modules - zsh completion function
+#
+# Adam Spiers <adam@spiers.net>
+#
+# Calculate all installed Perl modules.  The result is cached
+# for future use.
+#
+# Bugs:
+#   - can't cope with multiple installs of Perl
+
+# Change this if you have pminst and want to use it.  The zsh code
+# actually produces better results because pminst misses modules of
+# the form Foo/bar/Baz.pm through its clumsy -d && /^[A-Z]/ && prune
+# algorithm (the zsh code does almost the same, but only misses modules
+# which don't begin with an uppercase letter).
+local try_to_use_pminst=0
+
+if [[ ${+_perl_modules} -eq 0 ]]; then
+  if [[ $try_to_use_pminst -ne 0 ]] && which pminst >/dev/null; then
+    _perl_modules=( $(pminst) )
+  else
+    local inc libdir new_pms
+    inc=( $( perl -e 'print "@INC"' ) )
+    typeset -agU _perl_modules	# _perl_modules is global, no duplicates
+    _perl_modules=( )
+
+    for libdir in $inc; do
+        # Ignore cwd - could be too expensive e.g. if we're near /
+        if [[ $libdir == '.' ]]; then break; fi
+
+	# Find all modules
+	cd $libdir
+        new_pms=( {[A-Z]*/**/,}*.pm(N) )
+	cd $OLDPWD
+
+	# Convert to Perl nomenclature
+	new_pms=( ${new_pms:r:fs#/#::#} )
+
+        _perl_modules=( $new_pms $_perl_modules )
+    done
+  fi
+fi
+
+compadd - $_perl_modules
diff -urN zsh-3.1.6-clean/Completion/User/_perldoc zsh-3.1.6-adam/Completion/User/_perldoc
--- zsh-3.1.6-clean/Completion/User/_perldoc	Thu Jan  1 01:00:00 1970
+++ zsh-3.1.6-adam/Completion/User/_perldoc	Sun Sep  5 22:31:18 1999
@@ -0,0 +1,23 @@
+#compdef perldoc
+#
+#
+# _perldoc - zsh completion function for perldoc
+#
+# Adam Spiers <adam@spiers.net>
+#
+# Behaviour should be roughly equivalent to:
+# compctl -k perl_modules -k perl_basepods -f 
+#           -x 'c[-1,-f]' -k perl_funcs --
+#	  + -k man_pages
+#     perldoc
+
+if [[ $CURRENT -eq 3 && $words[2] == '-f' ]]; then
+  _perl_builtin_funcs
+elif [[ $CURRENT -eq 3 && $words[2] == '-q' ]]; then
+  zle -R "I can't read your mind!"
+else
+  _perl_modules
+  _perl_basepods
+  _path_files -/ -g '*.(pod|pm)'
+fi
+


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1999-09-07  9:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-06 11:37 PATCH: completion for perldoc Sven Wischnowsky
1999-09-06 18:18 ` Adam Spiers
1999-09-06 18:21   ` Adam Spiers
1999-09-07  8:57     ` Peter Stephenson
1999-09-07  9:18       ` Adam Spiers
  -- strict thread matches above, loose matches on Subject: below --
1999-09-07  9:02 Sven Wischnowsky
1999-09-07  8:59 Sven Wischnowsky
1999-09-07  8:32 Sven Wischnowsky
1999-09-07  9:49 ` Adam Spiers
1999-09-06  9:28 Sven Wischnowsky
1999-09-06 10:07 ` Adam Spiers
1999-09-05 21:38 Adam Spiers

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).