aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2009-11-10 20:05:24 -0800
committerRuss Cox <rsc@golang.org>2009-11-10 20:05:24 -0800
commitc57054f7b49539ca4ed6533267c1c20c39aaaaa5 (patch)
treeb68305599abee671f80890777d0bbf1163ed5921
parent022e3ae2659491e519d392e266acd86223a510f4 (diff)
downloadgo-c57054f7b49539ca4ed6533267c1c20c39aaaaa5.tar.gz
go-c57054f7b49539ca4ed6533267c1c20c39aaaaa5.zip
Implement new emacs command M-x gofmtweekly.2009-11-10.1
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
-rw-r--r--misc/emacs/go-mode.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el
index feba035ee5..47d790db41 100644
--- a/misc/emacs/go-mode.el
+++ b/misc/emacs/go-mode.el
@@ -470,3 +470,9 @@ Useful for development work."
(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))