summaryrefslogtreecommitdiff
path: root/misc/emacs/go-mode.el
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2009-11-10 20:05:24 -0800
committerKevin Ballard <kevin@sb.org>2009-11-10 20:05:24 -0800
commit7b3dbb03faf2b777d3ade8bb2c645a57192b4337 (patch)
tree86da442eaef40c76a539a39678abc9485bc86e14 /misc/emacs/go-mode.el
parentdf1b38aa7c09f7720e2e54ecfa6f92da11f4ceab (diff)
downloadgolang-7b3dbb03faf2b777d3ade8bb2c645a57192b4337.tar.gz
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 http://codereview.appspot.com/154044 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'misc/emacs/go-mode.el')
-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 feba035ee..47d790db4 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))