Created
September 22, 2010 06:53
-
-
Save senny/591254 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
(defun ruby-send-region (start end) | |
"Send the current region to the inferior Ruby process." | |
(interactive "r") | |
(let (term (file (buffer-file-name)) line) | |
(save-excursion | |
(save-restriction | |
(widen) | |
(goto-char start) | |
(setq line (+ start (forward-line (- start)) 1)) | |
(goto-char start) | |
(while (progn | |
(setq term (apply 'format ruby-send-terminator (random) (current-time))) | |
(re-search-forward (concat "^" (regexp-quote term) "$") end t))))) | |
;; compilation-parse-errors parses from second line. | |
(save-excursion | |
(let ((m (process-mark (inf-ruby-proc)))) | |
(set-buffer (marker-buffer m)) | |
(goto-char m) | |
(insert ruby-eval-separator "\n") | |
(set-marker m (point)))) | |
(comint-send-string (inf-ruby-proc) (format "eval <<'%s', nil, %S, %d\n" term (if file file "") (if line line ""))) | |
(comint-send-region (inf-ruby-proc) start end) | |
(comint-send-string (inf-ruby-proc) (concat "\n" term "\n")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment