Subject: 9menu and sam

From: [email-masked]
Date: Tue, 21 Feb 1995 14:08:25 -0500

I read the excellent article on the UNIX Plan 9 tools this weekend and realized
that I can extend sam.  I understand why basic sam doesn't have macro
capability, but there are some things that I do a lot that would be nice
to do with the mouse.  I use samx2, and wouldn't use sam without it, but while
it has macro capability, I'm not big on learning lots of arbitrary key
sequences, even my own.  For these reasons I've put together a 9menu containing
some basic sam commands that I need.  When I want one, I go out to the 9wm
menu, bring up 9menu, and make my choice.  It has made things much easier.

I include the script here in case anyone is interested.  Some of the specific
macros may be useful to others, and some will only be meaningful to me, but
I figured I would include some examples.  I wrote this in perl because I 
haven't gotten far enough into the 9 tools to use rc.

Beirne
----------------------------------------------------------------------

#!/usr/local/perl

($name) = getpwuid($>);
$pipe = '/tmp/.sam.'.$name.'.'.$ENV{'DISPLAY'};
$pipe =~ s/:0$/:0\.0/;
$pipe =~ s/\.0$// if (! -r $pipe);
exit if ($pipe =~ /^\s*$/);
$ENV{'SAMPIPE'} = $pipe;
exec "9menu", "-label", "sam menu", "-popdown",  "-iconic",
	"-geometry", "+0+0",
	'dashed line:echo "i/----------------------------------------------------------------------\\\\\n" >'.$ENV{'SAMPIPE'},
	'eroff memo template:echo "r $T/ermemo\n,x/Your_name/c/B. Konarski" >'.$ENV{'SAMPIPE'},
	'eroff preview:echo ",>preview" >'.$ENV{'SAMPIPE'},
	'eroff print:echo ",>tbl -D | eroff -mm -mr" >'.$ENV{'SAMPIPE'},
	'format:echo "|fmt" >'.$ENV{'SAMPIPE'},
	'shift left:echo "x/^	/d" >'.$ENV{'SAMPIPE'},
	'shift right:echo "x/^/a/	/" >'.$ENV{'SAMPIPE'},
	'spell:echo ",|cspell" >'.$ENV{'SAMPIPE'},
	"exit"	
----------------------------------------------------------------------

-- 
-------------------------------------------------------------------------------
Beirne Konarski                 | Reading maketh a full man, conference a
[email-masked]            | ready man, and writing an exact man.
"Untouched by Scandal"          |       -- Francis Bacon
-------------------------------------------------------------------------------