to apply against latest p9p tip:
cd $PLAN9 && patch -p1 < patch-acme.diff
mk and run with -g
The workflow for a go program is as follows:
type code
execute Put
execute Fmt (which is right next to Put)
if error execute Undo and go to the error location pointed to by gofmt's output
else execute Put again
BUGS: Since there's no way to check on an executed program's return
value an Fmt necessarily dirties the window, even if gofmt makes no
changes.
andrey
#!/bin/sh
set -e
tmp=/tmp/acmefmt.$$
trap "rm -f $tmp $tmp.1 $tmp.2" 0 1 2
w() {
9p write acme/$winid/$1
}
r() {
9p read acme/$winid/$1
}
ctl() {
echo -n "$@" | w ctl
}
wintag=$(r tag | sed 's/ .*//')
r body >$tmp
if ! gofmt <$tmp >$tmp.1 2>$tmp.2; then
sed "s:^<standard input>:$wintag:" $tmp.2
else
if ! cmp $tmp $tmp.1 >/dev/null; then
echo -n , | w addr
ctl dot=addr
cat $tmp.1 | w wrsel
echo -n 0 | w addr
ctl dot=addr
fi
fi
I admit I didn't think of the '9p' command at all.
If you do it in C (or Go; there are bindings) then you can
still make a real external program without any temporary files,
and it will work everywhere, not just where people have
patched acme. If you want it to be more convenient you
could install the binary as "P". :-)
Russ
Yes, that is what I do, using this: https://bitbucket.org/fhs/hgstyle
It's too easy to forget to run gofmt.
fhs