lab 65 - Man pages in Acme
NAME
lab 65 - Man pages in Acme
NOTES
This lab's purpose is to have man-pages opened in acme automatically. Easiest way to do this is to allow plumb to get it's data piped from another program. So we can do:man2txt /man/sec/file | plumb -i -d edit -a action showdata -a filename '/man/file(sec)';given that we want to plumb it to acme we have to set the destination port -d edit, and instruct acme to show the data with the tag set to the value of the filename argument. So now we can add to our plumbing rules something like:
# man pages kind is text data matches '([a-zA-Z0-9\-]+)\(([0-9]+)\)' plumb alwaysstart man # nasty plumbing hack plumb start /dis/sh.dis -c '/usr/salva/dis/man -b $2 $1'where /usr/salva/dis/man is an adaptation of /rc/bin/man from Plan9, and in particular when invoked with the -b option does:
man2txt $file | plumb -i -d edit -a action showdata -a filename '/man/'^${tl $*}^'('^${hd $*}^')'But if we now start to try running it as a substitue to te default rule for opening man pages, sooner or later we will find it crashes with the following error,
'Acme: can't read /chan/plumb.edit: buffer too short',that advice is generated from /appl/acme/acme.b:/plumbproc(). If we dig in the Msg.recv() code we will find that the data received from a channel is limited by maxdata, which is set when initializing the module plumbmsg.m, and gets it's value Dat->PLUMBSIZE in /appl/acme/acme.b:/init(.*), which is by default 1024, thus sending a file bigger that 1024 bytes will crash the plumbproc process. To sort out this we can determine the biggest data that we will send to the plumber, in particular issuing a:
du /man/*/* | sort -n | uniq | tail -n 1will return us the size of the biggest man page that we can reach, it turns out to be 58Kb, so we set PLUMBSIZE: con 65536, with the following ed script:
% ed /appl/acme/dat.m 5192 /PLUMBSIZE : con 1024/ s/1024/65536 PLUMBSIZE : con 65536; w 5193 qNow we cd /appl/acme and issue a
% mk && mk installand we're done. And last, we can addapt wurl2txt and wdoc2txt and add a pair of rules to our $home/lib/plumbing to have url's and .docs opened inside acme. You can make and script to emulate hget using
webgrab -r -o - http://url
Update:
After using the man script i wrote for this lab, i've decided that it's enought useful to replace the default /dis/man.dis, to do this i've changed the location of /appl/cmd/man.b to be /appl/lib/man.b (and modified PATH variable in man.m accordingly):% diff -e appl/lib/man.m.b appl/lib/man.m 37c PATH: con "/dis/lib/man.dis"; .This way is possible to use wm/man also from the man script (-p option). We just have to update it cd /appl/wm and issue a
% mk man.install
Comments