Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 2f9c63a4c6
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (41 sloc) 1.701 kB
(defconst jw-eval-buffer-commands
'(("js" . "/usr/local/bin/node")
("rb" . "/Users/jim/local/bin/ruby19")
("coffee" . "/usr/local/bin/coffee")
("clj" . "/Users/jim/local/bin/clojure")))
(defconst jw-eval-buffer-name "*EVALBUFFER*")
(defun jw-eval-buffer ()
"Evaluate the current buffer and display the result in a buffer."
(interactive)
(save-buffer)
(let* ((file-name (buffer-file-name (current-buffer)))
(file-extension (file-name-extension file-name))
(buffer-eval-command-pair (assoc file-extension jw-eval-buffer-commands)))
(if buffer-eval-command-pair
(let ((command (concat (cdr buffer-eval-command-pair) " " file-name)))
(shell-command-on-region (point-min) (point-max) command jw-eval-buffer-name nil)
(pop-to-buffer jw-eval-buffer-name)
(other-window 1)
(jw-eval-buffer-pretty-up-errors jw-eval-buffer-name)
(message ".."))
(message "Unknown buffer type"))))
(defun jw-eval-buffer-pretty-up-errors (buffer)
"Fix up the buffer to highlight the error message (if it contains one)."
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(let ((pos (search-forward-regexp "\\.rb:[0-9]+:\\(in.+:\\)? +" (point-max) t)))
(if pos (progn
(goto-char pos)
(insert-string "\n\n")
(end-of-line)
(insert-string "\n"))))))
(defun jw-clear-eval-buffer ()
(interactive)
(save-excursion
(set-buffer jw-eval-buffer-name)
(kill-region (point-min) (point-max))))
(defun jw-eval-or-clear-buffer (n)
(interactive "P")
(cond ((null n) (jw-eval-buffer))
(t (jw-clear-eval-buffer))) )
Jump to Line
Something went wrong with that request. Please try again.