From: Kevin Ballard Date: Wed, 11 Nov 2009 04:05:24 +0000 (-0800) Subject: Implement new emacs command M-x gofmt X-Git-Tag: weekly.2009-11-10.1 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c57054f7b49539ca4ed6533267c1c20c39aaaaa5;p=gostls13.git 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 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))