Created
September 18, 2010 16:20
-
-
Save klang/585812 to your computer and use it in GitHub Desktop.
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
| ;; runs the current buffer in the environment where the file resides. | |
| (defvar extention-to-executer-bindings ()) | |
| (add-to-list 'extention-to-executer-bindings '("pl" . "perl")) | |
| (add-to-list 'extention-to-executer-bindings '("php" . "php -f")) | |
| (add-to-list 'extention-to-executer-bindings '("sh" . "bash")) | |
| (defun lookup-executer (ext) | |
| "find appropriate executer for script" | |
| (interactive) | |
| (cdr (assoc ext extention-to-executer-bindings )) ) | |
| (defun execute-buffer-script () | |
| "executes the script in the current buffer" | |
| (interactive) | |
| (let ( (ext (first (last (split-string (buffer-name) "\\." t)))) ) | |
| (zerop (shell-command (concat (lookup-executer ext) " " (buffer-name)))))) | |
| (global-set-key [f10] 'execute-buffer-script) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment