Skip to content

Instantly share code, notes, and snippets.

@klang
Created September 18, 2010 16:20
Show Gist options
  • Select an option

  • Save klang/585812 to your computer and use it in GitHub Desktop.

Select an option

Save klang/585812 to your computer and use it in GitHub Desktop.
;; 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