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

Re: menuselection with manpages



Frank Terbeck <frank.terbeck@xxxxxxxxxxxxxx>:
> I'm using completion for the 'man' command with menuselection (sorted
> by sections). Now, if I enter 'man cron<TAB>' I am dropped into a
> selection for crontab(1) crontab(5) and cron(8).
[...]
> How would I get the completion to add the section to the completion,
> like 'man 5 crontab'?

Hi.
I found some time this evening, so I played around with the _man
function a little bit. The required change was pretty simple:

[snip]
--- _man.old    2006-05-18 23:46:40.000000000 +0200
+++ _man        2006-05-18 23:44:57.000000000 +0200
@@ -90,7 +90,7 @@
   # beginning with .<->: that handles problem cases like files called
   # `POSIX.1.5'.
 
-  compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
+  compadd "$@" -P "$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
 }
 
 _man "$@"
[snap]

This works pretty nice, however, if you do this:

  % man 5 cront<TAB>

it expands to:

  % man 5 5 crontab

which is not what I would want. How could I get this to work sanely?
As in: Only add the section if none was specified.

Regards, Frank



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