Created
March 10, 2014 05:55
-
-
Save copyninja/9460126 to your computer and use it in GitHub Desktop.
Go source formatter for ACME editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright: (c) Vasudev Kamath <[email protected]>, 2014 under the | |
# terms and conditions of MIT/Expat. | |
tmp=$(mktemp --tmpdir=$(pwd)) | |
etmp=$(mktemp --tmpdir=$(pwd)) | |
cleanup() { | |
rm -f "$tmp" "$etmp" | |
} | |
trap cleanup 0 INT QUIT | |
9p read acme/$winid/body | gofmt >"$tmp" 2>"$etmp" | |
if [ $(wc -l "$etmp" | awk '{print $1}') -eq 0 ]; then | |
if ! $(9p read acme/$winid/body | cmp $tmp /dev/stdin); then | |
echo -n "1,$" | 9p write acme/$winid/addr | |
cat $tmp | 9p write acme/$winid/data | |
echo -n '#0' | 9p write acme/$winid/addr | |
fi | |
else | |
# error occured lets write the error window | |
cat "$etmp" | 9p write acme/new/body | |
last=$(9p ls acme | sort -g | tail -n 1) | |
echo -n "clean" | 9p write acme/$last/ctl | |
echo -n "0,0" | 9p write acme/$last/addr | |
echo -n "dot=addr" | 9p write acme/$last/ctl | |
echo -n "show" | 9p write acme/$last/ctl | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment