Subject: sam and varios mail programs

From: [email-masked] (Arnold Robbins)
Date: Thu, 8 Dec 1994 11:35:37 -0500

Greetings.  I use 'mush' as my mail program, and I have my EDITOR environment
variable set to use sam.  The problem comes when I have a sam running, and
then I go to read mail. When I edit my file, it cranks up another sam. But
when that sam quits, it removes the fifo in /tmp that the `B' command uses.
At that point, I can no longer use `B' to communicate with my orignal sam.

My question is, how do *you* handle this?  Does anyone have a shell script
that runs B on their temporary mail file such that things stay in sync
after the file is written back out with sam?

(This has probably been discussed before...)

Thanks!

Arnold

---

From: Rich Salz <[email-masked]>
Date: Thu, 8 Dec 1994 11:50:24 -0500

I modified sam so that when creating the fifo it first did
	getenv("sampipe")
and if that existed it used that as the name of the pipe.  I set that
variable in my .rcrc which is sourced by my X startup stuff.

For editing I set VISUAL to $home/bin/callsam, which is this:
#! /bin/rc
~ $#* 1 || {
    echo Usage: `{basename $0} file >[1=2]
    exit 1
}

~ $#sampipe 0 && {
    sampipe=$home/.sam.$USER
    ! ~ $#DISPLAY 0 && sampipe=$sampipe.$DISPLAY
}
! test -r $sampipe && {
    echo `{basename $0} ^ ': No pipe "' ^ $sampipe ^ '" to sam' >[1=2]
    exit 1
}

{ switch ($1) {
case /*
    echo B $1
case *
    echo B `{builtin pwd} ^ / ^ $1
} }>$sampipe

echo Type EOF when done:
cat
# Could use "sed 1q" to get just a newline but I prefer the EOF.

---

From: [email-masked] (Arnold Robbins)
Date: Thu, 8 Dec 1994 11:56:35 -0500

> (various?)

*I* can spell. My keyboard can't, though. ☺

> why not change your EDITOR variable to be a script
> that uses B to get the file into sam,

This is the easy part.

> and some other
> signal or watchdog to get it back?

This is the hard part.  It happens that if I do something like this
with mush, and simply wait until I've finished with the editor, I'm ok,
but it's pretty fragile.  That's why I was wondering if someone else had
beat me to inventing this wheel.

---

From: [email-masked] (Jonathan Shopiro)
Date: Thu, 8 Dec 1994 02:55:49 -0500

I use mailx with sam as my editor.  I only have one instance of sam on
my workstation.  It works like this:

I invoke mailx with the following command:

	crt=50 PAGER=Bcat VISUAL=BB mailx

"crt=50" means if it's longer than 50 lines run it through the pager.

"PAGER=Bcat" means use Bcat (a shell script; see below) to display long messages.

"VISUAL=BB" means use BB (ditto) as the message editor

Then when I try to read a long message it appears in sam.  When I
compose a message I can type "~v" and the message so far appears in
sam.  I edit it until its perfect, select write, and go back to the
mailx window where I hit return and then send it.  It's a mess, really,
but it beats mailtool and textedit (no characterization sufficiently
derogatory).

Now for my question: has anybody gotten <exch> to work reliably with
sam and 9term under Solaris?  It seems to work for a while after
rebooting but then it doesn't work anymore.  I poked through the code
to some X function about swapping selections and then I gave up.  Also,
is it supposed to work to snarf in one 9term window and paste (the
snarfed text) into another?  That never works for me.

		-- Jonathan Shopiro
		   Merrill Lynch & Co.

Here are the shell scripts (simple modifications of B, both of them):

Bcat:
	#!/bin/sh
	
	file=$HOME/tmp/Bcat$$
	files=$file
	line="none"
	
	if [ $# != 0 ]; then
		echo 'usage: Bcat'  1>&2
		exit 1
	fi
	
	dir=`/bin/pwd`
	if [ "$USER" = "" ]; then
		USER=$LOGNAME
	fi
	pipe=/tmp/.sam.$USER
	
	if [ $DISPLAY != "" ]; then
		pipe=$pipe.$DISPLAY
	fi
	
	if [ ! -r $pipe ]; then
		echo `basename $0`": No pipe \""$pipe"\" to sam." 1>&2
		exit 1
	fi
	
	cat - >$file
	
	echo "B $files" >> $pipe
	if [ $line != "none" ]; then
		echo $line >> $pipe
	fi
	
	read dummy

BB:
	#!/bin/sh
	
	files=
	line="none"
	
	if [ $# = 0 ]; then
		echo 'usage: BB [-nnnn] files...'  1>&2
		exit 1
	fi
	
	dir=`/bin/pwd`
	if [ "$USER" = "" ]; then
		USER=$LOGNAME
	fi
	pipe=/tmp/.sam.$USER
	
	if [ $DISPLAY != "" ]; then
		pipe=$pipe.$DISPLAY
	fi
	
	if [ ! -r $pipe ]; then
		echo `basename $0`": No pipe \""$pipe"\" to sam." 1>&2
		exit 1
	fi
	
	for i in $*
	do
		case "$i" in
			/*)	files="$files $i"
				;;
			-*)	line=`echo $i | sed 's/.//'`
				;;
			*)	files="$files $dir/$i"
				;;
		esac
	done
	
	echo "B $files" >> $pipe
	if [ $line != "none" ]; then
		echo $line >> $pipe
	fi
	
	read dummy