Last active
August 29, 2015 14:21
-
-
Save belden/e3600a3d73e798ce516b to your computer and use it in GitHub Desktop.
Golang stuff for Logan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; this could use some improvement | |
;; | |
;; - it doesn't clean up the temp file | |
;; - it doesn't ensure there's a selected region | |
;; - etc. | |
;; | |
(defun logan/run-selected-golang-code () | |
"run the selected code as though it is golang code" | |
(interactive) | |
(let ((tempfile (format "%s.go" (make-temp-file "logan-golang")))) | |
(write-region (region-beginning) (region-end) tempfile) | |
(compile (format "go run %s" tempfile)))) | |
;; if you add the above function and this following line into your | |
;; ~/.emacs (which is a lousy way of doing things) then you can | |
;; highlight some code, then run "C-x g r" to "go-run this region" | |
(global-set-key (kbd "C-x g r") 'logan/run-selected-golang-code)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Load that code up, then in an emacs buffer, paste in this:
Highlight the
golang
code, then runM-x logan/run-selected-golang-code