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

Re: Few newbie questions..

On Aug 17, 10:39am, Jukka Lehti wrote:
} When I type for example 'man local' and hit tab
} I can choose from:
} locale.1 locale.3 locale.7
} I prefer the man completion to show me the section
} numbers (although I have remove the number before
} pressing enter since man can't find e.g. locale.1).


Before I go any further, I'll mention that with `compinit' zsh 4 is able
to complete only those pages that are available in a particular section,
so you can do e.g.

    zsh% man 7 lo<TAB>

and see only the pages that are in section 7.  I realize this is sort of
the inverse of what you were asking, but maybe it's of interest.

OK, moving on.  You must be using `compinit' or the compctl that you
described would still be working.  So you need to change the way that
the existing completion function adds matches.  Assuming that you have
4.0.2 (it changed since 4.0.1) the following should fix you up.

First, make a copy of the _man function definition:

    mkdir ~/zshfuncs
    cp $^fpath/_man(|)(N) ~/zshfuncs

The (|)(N) silliness is just to ignore the directories in $fpath where
there is no _man file.  Look up "glob qualifiers" in the manual.

Edit ~/zshfuncs/_man to change the _man_pages helper function (which is
also defined in the _man file) as shown below:

    _man_pages() {
	local matcher pages dummy
	zparseopts -E M+:=matcher
	if (( $#matcher ))
	compfiles -p pages '' '' "$matcher" '' dummy '*'
	pages=($~pages(:t)) 				# CHANGED
	(($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) 
	compadd "$@" -a pages				# CHANGED

That fixes _man_pages so as to keep the file suffixes when adding the
completions.  It'll have to be updated if _man changes again in another
zsh release, but it's the best that can be done in the circumstances.

Then, in your .zshrc somewhere -after- you call `compinit', add:

    fpath=(~/zshfuncs $fpath)

Thus your _man file will be found before the installed one, and you'll
see the file suffixes.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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