* menuselection with manpages
@ 2006-05-17 15:10 Frank Terbeck
2006-05-18 22:09 ` Frank Terbeck
0 siblings, 1 reply; 6+ messages in thread
From: Frank Terbeck @ 2006-05-17 15:10 UTC (permalink / raw)
To: zsh users
Howdy,
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).
It looks like this:
[snip]
% man crontab
- manual page, section 1 -
crontab
- manual page, section 5 -
crontab
- manual page, section 8 -
cron
[snap]
If I want to read crontab(5) and choose the crontab entry from the 5th
section in the menu, it will be completed as 'man crontab' which would
display crontab(1).
How would I get the completion to add the section to the completion,
like 'man 5 crontab'?
Regards, Frank
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: menuselection with manpages
2006-05-17 15:10 menuselection with manpages Frank Terbeck
@ 2006-05-18 22:09 ` Frank Terbeck
2006-05-19 3:28 ` Bart Schaefer
2006-05-19 8:31 ` Oliver Kiddle
0 siblings, 2 replies; 6+ messages in thread
From: Frank Terbeck @ 2006-05-18 22:09 UTC (permalink / raw)
To: zsh users
Frank Terbeck <frank.terbeck@rwth-aachen.de>:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: menuselection with manpages
2006-05-18 22:09 ` Frank Terbeck
@ 2006-05-19 3:28 ` Bart Schaefer
2006-05-19 4:38 ` Frank Terbeck
2006-05-19 8:31 ` Oliver Kiddle
1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2006-05-19 3:28 UTC (permalink / raw)
To: zsh users
On May 19, 12:09am, Frank Terbeck wrote:
} Subject: Re: menuselection with manpages
}
} - compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
} + compadd "$@" -P "$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
}
} % man 5 5 crontab
}
} which is not what I would want. How could I get this to work sanely?
Try:
if ((CURRENT > 2))
then compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
else compadd "$@" -P "$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
fi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: menuselection with manpages
2006-05-19 3:28 ` Bart Schaefer
@ 2006-05-19 4:38 ` Frank Terbeck
0 siblings, 0 replies; 6+ messages in thread
From: Frank Terbeck @ 2006-05-19 4:38 UTC (permalink / raw)
To: zsh users
Bart Schaefer <schaefer@brasslantern.com>:
> On May 19, 12:09am, Frank Terbeck wrote:
> } Subject: Re: menuselection with manpages
> } - compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
> } + compadd "$@" -P "$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
> } % man 5 5 crontab
> } which is not what I would want. How could I get this to work sanely?
>
> Try:
> if ((CURRENT > 2))
> then compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
> else compadd "$@" -P "$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
> fi
Hi Bart,
That's not what I had in mind first, but actually I like it even
better. And quite simple... why didn't I try that? :-)
Thanks a lot.
Regards, Frank
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: menuselection with manpages
@ 2006-05-19 8:31 ` Oliver Kiddle
2006-05-20 8:10 ` Frank Terbeck
0 siblings, 1 reply; 6+ messages in thread
From: Oliver Kiddle @ 2006-05-19 8:31 UTC (permalink / raw)
To: zsh users
[-- Attachment #1: Type: text/plain, Size: 790 bytes --]
Frank Terbeck wrote:
> > How would I get the completion to add the section to the
completion,
> > like 'man 5 crontab'?
> I found some time this evening, so I played around with the _man
> function a little bit. The required change was pretty simple:
Very nice!
This should be configurable with a style. I've attached a patch which
does that. This also means that section 1 can be excluded as follows:
zstyle ':completion:*:manuals.(^1*)' insert-sections true
I prefer this, especially on Solaris because there the prefix needs to
include the -s option and that is then a common prefix to all matches.
Oliver
PS. Sorry for seperately attaching the patch but otherwise Yahoo's
webmail would wrap the lines.
Send instant messages to your online friends http://uk.messenger.yahoo.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 817113010-mansect.patch --]
[-- Type: text/x-patch; name="mansect.patch", Size: 1519 bytes --]
--- _man.orig Fri May 19 09:55:05 2006
+++ _man Fri May 19 10:24:10 2006
@@ -28,7 +28,7 @@
local sect
if [[ $OSTYPE = solaris* ]]; then
- sect=$words[$words[(i)-s]+1]
+ sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]}
elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then
if [[ $sect != ${sect::="${sect//:/|}"} ]]; then
sect="($sect)"
@@ -44,7 +44,11 @@
dirs=( $^_manpath/(sman|man|cat)*/ )
awk='{print $1}'
fi
- if zstyle -t ":completion:${curcontext}:manuals" separate-sections; then
+ if [[ $OSTYPE = solaris* && ( $words[CURRENT] = -s* || $words[CURRENT-1] == -s ) ]]; then
+ [[ $words[CURRENT] = -s* ]] && compset -P '-s'
+ sects=( ${(o)${dirs##*(man|cat)}%/} )
+ _wanted sections expl 'section' compadd -a sects
+ elif zstyle -t ":completion:${curcontext}:manuals" separate-sections; then
typeset -U sects
local ret=1
@@ -69,7 +73,7 @@
}
_man_pages() {
- local matcher pages dummy
+ local matcher pages dummy sopt
zparseopts -E M+:=matcher
@@ -90,7 +94,14 @@
# beginning with .<->: that handles problem cases like files called
# `POSIX.1.5'.
- compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
+ [[ $OSTYPE = solaris* ]] && sopt='-s '
+ if ((CURRENT > 2)) ||
+ ! zstyle -t ":completion:${curcontext}:manuals.$sect" insert-sections
+ then
+ compadd "$@" - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
+ else
+ compadd "$@" -P "$sopt$sect " - ${pages%.(?|<->*(|.gz|.bz2|.Z))}
+ fi
}
_man "$@"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: menuselection with manpages
2006-05-19 8:31 ` Oliver Kiddle
@ 2006-05-20 8:10 ` Frank Terbeck
0 siblings, 0 replies; 6+ messages in thread
From: Frank Terbeck @ 2006-05-20 8:10 UTC (permalink / raw)
To: zsh users
Oliver Kiddle <okiddle@yahoo.co.uk>:
> Frank Terbeck wrote:
> > > How would I get the completion to add the section to the
> > > completion, like 'man 5 crontab'?
>
> > I found some time this evening, so I played around with the _man
> > function a little bit. The required change was pretty simple:
> This should be configurable with a style. I've attached a patch which
> does that. This also means that section 1 can be excluded as follows:
> zstyle ':completion:*:manuals.(^1*)' insert-sections true
Hi Oliver,
That works great. Thank you, too.
Regards, Frank
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-05-20 8:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-17 15:10 menuselection with manpages Frank Terbeck
2006-05-18 22:09 ` Frank Terbeck
2006-05-19 3:28 ` Bart Schaefer
2006-05-19 4:38 ` Frank Terbeck
2006-05-19 8:31 ` Oliver Kiddle
2006-05-20 8:10 ` Frank Terbeck
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).