Last active
December 21, 2015 16:09
-
-
Save krrrr38/6331377 to your computer and use it in GitHub Desktop.
This file contains 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
(defun run-script-region () | |
"指定範囲内のコードをスクリプトとして実行します" | |
(interactive) | |
(if (>= (region-beginning) (region-end)) | |
(message "no selected region") | |
(let* ((run-script-region-file-path "/tmp/run-script-region") | |
(extention (progn | |
(string-match "\\..*" (buffer-name)) | |
(substring (buffer-name) (+ (match-beginning 0) 1) (match-end 0)))) | |
(command (cond ((equal extention "js") "node") | |
((member extention '("pl" "pm" "t")) "perl") | |
((equal extention "py") "python") | |
((equal extention "rb") "ruby") | |
((equal extention "scala") "scala") | |
((equal extention "sh") "sh")))) | |
(write-region (region-beginning) (region-end) run-script-region-file-path nil) | |
(compile (format "%s %s" command run-script-region-file-path))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment