Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Completion for man (_man) patch to support -M



On Thu, Oct 21, 2010 at 08:29:12PM +0100, Peter Stephenson wrote:
> On Thu, 21 Oct 2010 13:15:14 -0200
> Silas Silva <silasdb@xxxxxxxxx> wrote:
> > I was studying the completion system and, since I would like to add
> > support for -M for the _man completion, I've done it.  Dirty and ugly
> > patch is attached.
> 
> Not sure how widespread support for that argument is, certainly man is
> historically rather different on different systems, but _man already
> doesn't look much like other completion functions, and the intention
> here is obvious enough, so I've committed it.

Yeah...  I tested it under NetBSD and GNU/Linux.  It might work under
other BSDs as well, but I don't know about other Unices.

> > I'm just not sure if it is the better way to do it.  opt holds the
> > option passed to the -M flag, but (( $words[(I)-M]+1 )) looks ugly?
> 
> Well, apart from the obvious use of a variable (and omitting the
> parentheses),
> 
>   integer ind=$words[(I)-M]
>   if (( ind )); then
>     local opt
>     opt=$words[ind+1]
>     _manpath=($_manpath $opt)
>   fi
> 
> I don't see a major improvement.   (I'll commit this improvement on top.)

Yeah, having the obvious use of a variable is a good practice.  Thanks
for the lesson and for the commit.   :-)

-- 
Silas Silva



Messages sorted by: Reverse Date, Date, Thread, Author