summaryrefslogtreecommitdiff
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
commit3cef66704512cad3298b4dcd3d86753879658dcd (patch)
tree86da442eaef40c76a539a39678abc9485bc86e14
parent9ca5aca0c925b75ffd4542a834b6ea6bf4966c64 (diff)
downloadgo-weekly.2009-11-10.1.tar.gz
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 http://codereview.appspot.com/154044 Committer: Russ Cox <rsc@golang.org>
-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))