zsh-users
 help / color / mirror / code / Atom feed
* completion control for "man" command
@ 1998-06-13 18:40 Sven Guckes
  1998-06-13 23:50 ` Thomas Köhler
  1998-06-14  0:29 ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Sven Guckes @ 1998-06-13 18:40 UTC (permalink / raw)
  To: zsh-users; +Cc: Johan Sundström

Hey!

Rather than keeping this mail to myself and trying the impossible [;-)] I'll
forward this to the experts on the zsh-users mailist. Hope you don't mind.
(And I hope it answers your question on a "public forum" for zsh, Johan. :-)

I wonder - hasn't the completion control for manuals been perfected by now?

Sven

----- Forwarded message from Johan Sundström <johsu650@student.liu.se> -----

From: "Johan Sundström" <johsu650@student.liu.se>
To: "Sven Guckes" <guckes@math.fu-berlin.de>
Subject: Compctl ... -- man
Date: Sat, 13 Jun 1998 20:06:28 +0200
X-Mailer: Microsoft Outlook Express 4.72.3110.1

I've been trying to fix a pleasant completion behaviour for the "man"
command, looking at files in the directories named in the vector $manpath,
in the order they are presented there. I guess I should build some
intelligent for structure that traverses the array and builds up some
intricate compctl commandline that is finally executed, but I'm not sure how
it should be accomplished. Could the -g globbing be used in some clever way?
We're looking at matching files matching a given pattern in a set of
directories, cutting out just a part of the filename path (something like
'(:t:r)' in my figlet setup, although not only cutting away the last
extension but all present; turning "/usr/man/man1/zshcompctl.1.gz" to
"zshcompctl").

Maybe I'm seriously overambitious about this one, but it would be *very*
convenient to have completion for the man command. Perhaps it will take a
bit too long to dive through all these directories everytime the completion
is executed, and thus should be done initially, from .zshrc? Any suggestions
on how to accomplish this?

Is there a public forum somewhere (on the web?), where people announce their
clever compctl completions and similar clever zsh tricks? It would do a
great deal to help newcomers learn and other benefit from eachothers ideas
and cleverness/laziness. :) I've just recently started to learn the sheer
potential for the command, and I can frankly say that I'm amazed. I played
around for a while, and ended up with a cute figlet completion:

compctl -x 'C[-1,-f]' -g '/usr/share/figlet/*.flf(:t:r)' - 'C[-1,-d]' -g
'*(/)' -- figlet

(Sure, it's not perfect; there's no clever -C parameter completion
behaviour, but hey, I'm just a newbie :-)

/Johan Sundström, happy Red Hat Linux user

----- End forwarded message -----


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

* Re: completion control for "man" command
  1998-06-13 18:40 completion control for "man" command Sven Guckes
@ 1998-06-13 23:50 ` Thomas Köhler
  1998-06-15  0:18   ` Sven Guckes
  1998-06-14  0:29 ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Köhler @ 1998-06-13 23:50 UTC (permalink / raw)
  To: zsh-users; +Cc: Johan Sundström, Sven Guckes

Hello,

On Sat, Jun 13, 1998 at 08:40:12PM +0200, Sven Guckes wrote:

> Hey!
> 
> Rather than keeping this mail to myself and trying the impossible [;-)] I'll
> forward this to the experts on the zsh-users mailist. Hope you don't mind.
> (And I hope it answers your question on a "public forum" for zsh, Johan. :-)
> 
> I wonder - hasn't the completion control for manuals been perfected by now?
> 
> Sven
[message on "how do I complete manpages?" deleted]

I use the following for man completion. It uses a file ~/tmp/_man_ which
stores the filenames in question. If you don't like your loginshell to
wait for the creation of the file every now and then (I use 14 days)
because it creates the _man_-file, just make a cronjob out of this...

------------------------------ snip ~/.zshrc ------------------------------
# completion for manpages
# if ~/tmp/_man_ is too old then remove it and create a new one later
find ~/tmp -mtime 14 -name "_man_" -exec rm -f {} \;

createman () {
   echo "creating ~/tmp/_man_"
   # search the filenames which should be included later...
   find /usr/man -type f > ~/tmp/_man_
   find /usr/local/man -type f >> ~/tmp/_man_
   find /usr/X11R6/man -type f >> ~/tmp/_man_
   # remove pathname, .gz-suffix and the section-number, use sort & uniq
   # to get an ordered list of filenames
   sed -e "s/.*\///" -e "s/\.gz//" -e "s/\.[^.]*$//" ~/tmp/_man_ | sort | uniq > ~/tmp/_man2_
   rm -f ~/tmp/_man_
   # put all on one line
   (for i in `cat ~/tmp/_man2_` ; do echo -n "$i " ; done) > ~/tmp/_man_
   rm -f ~/tmp/_man2_
}
# create ~/tmp/_man_
if [ ! -f ~/tmp/_man_ ] ; then createman ; fi

# invoke compctl on file list
man_pages=(`cat ~/tmp/_man_`)
compctl -f -k man_pages man
------------------------------ snip ~/.zshrc ------------------------------

HTH,
Thomas

-- 
    Thomas Köhler    Email:     jean-luc@picard.franken.de
        <><           WWW:    http://home.pages.de/~jeanluc/
                      IRC:               jeanluc
      LCARS --- Linux for Computers on All Real Starships


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

* Re: completion control for "man" command
  1998-06-13 18:40 completion control for "man" command Sven Guckes
  1998-06-13 23:50 ` Thomas Köhler
@ 1998-06-14  0:29 ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 1998-06-14  0:29 UTC (permalink / raw)
  To: Sven Guckes, zsh-users; +Cc: Johan Sundström

On Jun 13,  8:40pm, Sven Guckes wrote:
} Subject: completion control for "man" command
}
} I wonder - hasn't the completion control for manuals been perfected by now?

There were several different compctls for the "man" command posted to
zsh-users earlier this year.  Check out the mailing list archives at
www.zsh.org.


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


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

* Re: completion control for "man" command
  1998-06-13 23:50 ` Thomas Köhler
@ 1998-06-15  0:18   ` Sven Guckes
  1998-06-15  1:36     ` Bart Schaefer
  1998-06-15  8:54     ` Thomas Koehler
  0 siblings, 2 replies; 6+ messages in thread
From: Sven Guckes @ 1998-06-15  0:18 UTC (permalink / raw)
  To: zsh-users

Quoting Thomas Köhler (jean-luc@picard.franken.de):
> I use the following for man completion. It uses a file ~/tmp/_man_ which
> stores the filenames in question. If you don't like your loginshell to
> wait for the creation of the file every now and then (I use 14 days)
> because it creates the _man_-file, just make a cronjob out of this...

Well, I wouldn't want my completion control to rely on the existence of a file
in /tmp - after all everybody at our site is allowed to delete files in /tmp.
:-/  Besides, I wouldn't want to set up a cron job for this, either.

Now, if I can get our sysadmin (hi, Stucki) to create a little database
on man pages (with a cronjob or whatever) - that's fine. And, yes, I do
believe this job can be done with the help of awk, sed, and perl.  ;-)

But aren't we discussing the zsh here?  Shouldn't there be a way to do
the job with the zsh alone?   I'd rather see an elegant solution with
a few commands within the zsh than a perfomant database solution with
SAP's R/3 using a Alpha with 4G RAM.  ;-)

Also, I wouldn't mind some more examples in the zsh manuals...

Sven  [who promises to add all his zsh examples to his zsh page SOON]


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

* Re: completion control for "man" command
  1998-06-15  0:18   ` Sven Guckes
@ 1998-06-15  1:36     ` Bart Schaefer
  1998-06-15  8:54     ` Thomas Koehler
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 1998-06-15  1:36 UTC (permalink / raw)
  To: Sven Guckes, zsh-users

On Jun 15,  2:18am, Sven Guckes wrote:
} Subject: Re: completion control for "man" command
}
} But aren't we discussing the zsh here?  Shouldn't there be a way to do
} the job with the zsh alone?

http://www.zsh.org/mla/users-1998-hyper/0060.html

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


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

* Re: completion control for "man" command
  1998-06-15  0:18   ` Sven Guckes
  1998-06-15  1:36     ` Bart Schaefer
@ 1998-06-15  8:54     ` Thomas Koehler
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Koehler @ 1998-06-15  8:54 UTC (permalink / raw)
  To: Sven Guckes; +Cc: zsh-users

On Mon, Jun 15, 1998 at 02:18:59AM +0200, Sven Guckes wrote:

> Quoting Thomas Köhler (jean-luc@picard.franken.de):
> > I use the following for man completion. It uses a file ~/tmp/_man_ which
> > stores the filenames in question. If you don't like your loginshell to
> > wait for the creation of the file every now and then (I use 14 days)
> > because it creates the _man_-file, just make a cronjob out of this...
> 
> Well, I wouldn't want my completion control to rely on the existence of a file
> in /tmp - after all everybody at our site is allowed to delete files in /tmp.
> :-/

That's why I use ~/tmp ;-) See the difference? :-)

> Besides, I wouldn't want to set up a cron job for this, either.

Well, I have that in my .zshrc, no cronjob needed. But then, sometimes
the creating of the list when logging in is annoying...

> Now, if I can get our sysadmin (hi, Stucki) to create a little database
> on man pages (with a cronjob or whatever) - that's fine. And, yes, I do
> believe this job can be done with the help of awk, sed, and perl.  ;-)

Or zsh ;-)

> But aren't we discussing the zsh here?  Shouldn't there be a way to do
> the job with the zsh alone?   I'd rather see an elegant solution with
> a few commands within the zsh than a perfomant database solution with
> SAP's R/3 using a Alpha with 4G RAM.  ;-)

Well... my completion was written within 3 minutes and I didn't test how
long it would take to find all the manpages on-the-fly. But if I think
how long it takes to build the file (some seconds), I think it's too
slow to run every time I need the completion...

> Also, I wouldn't mind some more examples in the zsh manuals...

OK, acknowledged :)

> Sven  [who promises to add all his zsh examples to his zsh page SOON]

*looking*
tips.html is pretty cool :-)
compctl.html should have more explanations, but is OK :)

CU,
Thomas [still not having a zsh page]

-- 
    Thomas Köhler    Email:     jean-luc@picard.franken.de
        <><           WWW:    http://home.pages.de/~jeanluc/
                      IRC:               jeanluc
      LCARS --- Linux for Computers on All Real Starships


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

end of thread, other threads:[~1998-06-15  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-13 18:40 completion control for "man" command Sven Guckes
1998-06-13 23:50 ` Thomas Köhler
1998-06-15  0:18   ` Sven Guckes
1998-06-15  1:36     ` Bart Schaefer
1998-06-15  8:54     ` Thomas Koehler
1998-06-14  0:29 ` Bart Schaefer

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