From c57054f7b49539ca4ed6533267c1c20c39aaaaa5 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Tue, 10 Nov 2009 20:05:24 -0800 Subject: [PATCH] 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 --- misc/emacs/go-mode.el | 6 ++++++ 1 file changed, 6 insertions(+) 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)) -- 2.48.1