I posted wrong code for Plan 9 by error.
The E script:
-----------------
#!/bin/rc
files=()
dest=()
if(~ $#* 0){
echo usage: E file ... >[1=2]
exit usage
}
for(i)
switch($i){
case /*
files = ( $files $i )
case *
files = ( $files `{cleanname `{pwd}^/$i} )
}
if(test -f /mnt/term/srv/sam.$user) dest = /mnt/term/srv/sam.$user
if not if(test -f /srv/sam.$user) dest = /srv/sam.$user
if not {
switch($files){
case *:*
for(i in $files){
fi = `{echo $i | sed 's/(.*):[^:]*/\1/'}
ad = `{echo $i | sed 's/.*:([^:]*)/\1/'}
plumb -d edit -a 'addr='$"ad'' $fi
}
case *
plumb -d edit $files
}
exit
}
switch($files){
case *:*
for(i in $files)
echo $i | sed 's/^/B /;s/:(.*)$/\n\1/g' >> $dest
case *
echo B $files >> $dest
}
-----------------
The plumb rules:
-----------------
# existing files, possibly tagged by line number, go to editor
type is text
data matches '([.a-zA-Z¡-�0-9_/+\-]*[a-zA-Z¡-�0-9_/+\-])('$addr')?'
arg isfile $1
plumb start E $file:$3
## man index entries are synthesized
type is text
data matches '([a-zA-ZÀ-ʨ¡-�0-9_-./+\-]+)\(([1-8])\)'
plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest =
/mnt/term/srv/sam.$user; if not if(test -f /srv/sam.$user) dest =
/srv/sam.$user; if not {man '$2' '$1' >[2=1] | plumb -i -d edit -a
''action=showdata filename=/man/'$1'('$2')''; exit}; {echo ''{}''; echo ''B
~~'$1'('$2')~~''; echo ''<man '$2' '$1' >[2=1]''} >>$dest'
# poor man's sam file browser
type is text
data matches '([.a-zA-Z¡-�0-9_/\-;&$,'']+)'
arg isdir $0
plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest =
/mnt/term/srv/sam.$user; if not if(test -f /srv/sam.$user) dest =
/srv/sam.$user; if not {plumb -d edit '$dir'; exit}; cd '$dir'; DIR = `{pwd};
{echo ''{}''; echo B $DIR/~~samdir~~; echo '',<echo ~~''$DIR''~~; echo; echo
../;ls -pF ''$DIR''''; echo 0} >>/srv/sam.$user'
## poor man's sam exec in current file's cwd
type is text
data matches '(¤)([a-zA-ZÀ-ʨ¡-�0-9_\-./\+^,()$:|#%<>*&'' ]+)'
plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest =
/mnt/term/srv/sam.$user; if not if(test -f /srv/sam.$user) dest =
/srv/sam.$user; if not {echo can''''t find sam server file >[1=2]; exit open};
{cd '$wdir'; {echo '$wdir' ¤'''$2'''; echo; {'$2'}; echo} >/tmp/sam_ecfcwd_$pid
>[2=1]; {echo ''{}''; echo B '$wdir'^/~~cmd~~; echo ''$''; echo ''<cat
/tmp/sam_ecfcwd_''$pid; echo ''!rm /tmp/sam_ecfcwd_''$pid} >>$dest}'
-----------------
I've tested it in 9front, and all works good. Of course you can delete
all the acme part if you don't use it.
Remember that you have to edit samterm/io.c to create always the pipe
[...]
hoststart();
plumbstart();
extstart();
}
And in P9P you need to set the shell to rc in sam/unix.c
#define SHNAME "rc"
#define SHPATHNAME "/usr/local/plan9/bin/rc"
Or adapt the rules for sh...
trebol.