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 1
will 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
q
Now we cd /appl/acme and issue a
% mk && mk install
and 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

FILES

caerwyn.com/lab/65

Comments

Popular posts from this blog

lab 110 - inferno archive edition

I've been occupied recently with archiving my digital media. I've been copying home videos on DV tapes to hard-disk, ripping audio CD's to WAV files, gathering photo collections, and trying to copy documents from Iomega disks, floppies, and my dusty old Acorn RiscPC. The plan is to have a copy of this data to give to each of my children. My Dad recently scanned and sent me all his photographs of me and my siblings growing up; he also included pictures of himself and my Mother when they met in Africa. With technology today each generation can build a digital library of family history to hand on to the next generation. In the past a family album may have been passed on to only one person. The accumulation of digital data still presents problems. It requires discipline to store files that are open and not locked into devices or proprietary formats. With digital preservation in mind I've tried to use file formats recommended for long term archiving. WAV files for audio, D...

lab 109 - wm/view true color

There has been a three and a half year gap in my posts to this blog. In that time I hadn't done any Limbo programming. I've used Acme as my editor everyday, but I was drifting towards using Notepad++ more often. In the past couple of months I've had the time to contemplate doing some hacking projects. I wanted to explore what I could do with Inferno for multimedia file types. This lab was the first thing I tackled in using Inferno again. I had to open up the Limbo paper to remember even some basic syntax. It bothered me that wm/view only displayed images using the Inferno 256 color map. Charon didn't have this limitation and I thought it had something to do with their respective image libraries. They don't use the same code. I extracted Charon's img.b code out into another view tool only to realize once I'd finished that the difference was not in the handling of JPEGs or PNGs but in the remap of the raw image to an Inferno image after the image was load...

lab 52 - text files

NAME lab 52 - text files NOTES Some limbo programs can be replaced with shell one liners, and others can be replaced with more general programs that reduce the limbo line count but increase functionality. I'll look at the few I've discovered. The /prog filesystem exposes a textual interface that allows existing software tools to work with it. This implies I do not need a custom set of limbo tools to read and write to this filesystem. For example, ps is a 61 line limbo program, but I can do the same thing in one line of shell, fn ps {sed '' /prog/*/status |sort -n} This is the great power of Inferno. Simple textual interfaces exposed as files and a small set of software tools working together. Therefore, I can also try rewriting kill and broke . In this case I make the functionality more like Plan 9. Each command writes to output the commands that can be sent back to the shell to actually perform the kill action. fn kill { sed -n '/' ^ 1ドル ^ '/s/^ +...