Implement new emacs command M-x gofmt
Define a new interactive function in go-mode.el called gofmt.
This function passes the current buffer through the external `gofmt`
tool and replaces the buffer with the result.
R=agl, rsc
https://golang.org/cl/154044
diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el
index feba035..47d790d 100644
--- a/misc/emacs/go-mode.el
+++ b/misc/emacs/go-mode.el
@@ -470,3 +470,9 @@
(go-mode))
(provide 'go-mode)
+
+(defun gofmt ()
+ "Pipe the current buffer through the external tool `gofmt`."
+
+ (interactive)
+ (shell-command-on-region 1 (+ (buffer-size) 1) "gofmt" t t shell-command-default-error-buffer))