; current-buffer-name.go; make current-buffer-name && ./current-buffer-name(defun compile-run () (interactive) (setq name (first (split-string (buffer-name (current-buffer)) "[.]"))) (compile (format "make %s && ./%s" name name)))
; assigns hyper-m (I have the Windows key set as hyper) to running compile-run(global-set-key (kbd "H-m") 'compile-run)
And the piece of my Makefile that handles this:
%: %.go 6g $^ 6l -o $@ $@.6
You'll have to tweak the Makefile stuff if you want to compile for anything other than amd64.
The compile-run function should actually work for any language, as long as you get the Makefile set up correctly.
Edit: Here's a version that just compiles and doesn't run the current buffer (you'll still need the same Makefile entry above)
(defun compile-buffer () (interactive) (setq name (first (split-string (buffer-name (current-buffer)) "[.]"))) (compile (format "make %s" name)))
; Sets meta-m (AKA alt-m or escape-m, or command-m on Macs)(global-set-key (kbd "M-m") 'compile-buffer)