]> Cypherpunks repositories - gostls13.git/commitdiff
Implement new emacs command M-x gofmt weekly.2009-11-10.1
authorKevin Ballard <kevin@sb.org>
Wed, 11 Nov 2009 04:05:24 +0000 (20:05 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 11 Nov 2009 04:05:24 +0000 (20:05 -0800)
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

index feba035ee50c91e4ef8f2274ba5f030972e4b091..47d790db41745fbd1f4e27733f4f933e3b2f12d2 100644 (file)
@@ -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))