summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-07 14:37:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-07 14:37:26 +0000
commit75821a5afba9c19a3eedeb4a092aade1ad21209a (patch)
tree932306de7d5aea342c93d0a864b89cba70bff7c2 /misc
parent9d64fd035aa2ec89dde826e27e9163f476477966 (diff)
* misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
alist for error message from ruby. * misc/inf-ruby.el (inferior-ruby-mode): fixed for Emacs. * misc/inf-ruby.el (ruby-send-region): compilation-parse-errors doesn't parse first line, so insert separators before each evaluations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc')
-rw-r--r--misc/inf-ruby.el52
1 files changed, 37 insertions, 15 deletions
diff --git a/misc/inf-ruby.el b/misc/inf-ruby.el
index 21b203dd91..0dda55dfda 100644
--- a/misc/inf-ruby.el
+++ b/misc/inf-ruby.el
@@ -35,18 +35,28 @@
;;; HISTORY
;;; senda - 8 Apr 1998: Created.
;;; $Log$
+;;; Revision 1.6 2002/09/07 14:35:46 nobu
+;;; * misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
+;;; alist for error message from ruby.
+;;;
+;;; * misc/inf-ruby.el (inferior-ruby-mode): fixed for Emacs.
+;;;
+;;; * misc/inf-ruby.el (ruby-send-region): compilation-parse-errors
+;;; doesn't parse first line, so insert separators before each
+;;; evaluations.
+;;;
;;; Revision 1.5 2002/08/19 10:05:47 nobu
;;; * misc/inf-ruby.el (inf-ruby-keys): ruby-send-definition
;;; conflicted with ruby-insert-end.
-;;;
+;;;
;;; * misc/inf-ruby.el (inferior-ruby-mode): compilation-minor-mode.
-;;;
+;;;
;;; * misc/inf-ruby.el (ruby-send-region): send as here document to
;;; adjust source file/line. [ruby-talk:47113], [ruby-dev:17965]
-;;;
+;;;
;;; * misc/inf-ruby.el (ruby-send-terminator): added to make unique
;;; terminator.
-;;;
+;;;
;;; Revision 1.4 2002/01/29 07:16:09 matz
;;; * file.c (rb_stat_rdev_major): added. [new]
;;;
@@ -122,10 +132,9 @@
(defvar inferior-ruby-mode-map nil
"*Mode map for inferior-ruby-mode")
-(pushnew '(ruby ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\):in \`.*\'$" 1 2))
- compilation-error-regexp-alist-alist)
-(pushnew '(ruby ("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2))
- compilation-error-regexp-alist-alist)
+(defconst inferior-ruby-error-regexp-alist
+ '(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
+ ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
(cond ((not inferior-ruby-mode-map)
(setq inferior-ruby-mode-map
@@ -200,8 +209,9 @@ to continue it."
(use-local-map inferior-ruby-mode-map)
(setq comint-input-filter (function ruby-input-filter))
(setq comint-get-old-input (function ruby-get-old-input))
- (compilation-minor-mode)
- (compilation-build-compilation-error-regexp-alist)
+ (compilation-shell-minor-mode t)
+ (make-local-variable 'compilation-error-regexp-alist)
+ (setq compilation-error-regexp-alist inferior-ruby-error-regexp-alist)
(run-hooks 'inferior-ruby-mode-hook))
(defvar inferior-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
@@ -268,16 +278,28 @@ of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
"Template for irb here document terminator.
Must not contain ruby meta characters.")
+(defconst ruby-eval-separator "")
+
(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
- (goto-char start)
- (setq line (line-number))
- (while (progn
- (setq term (apply 'format ruby-send-terminator (random) (current-time)))
- (re-search-forward (concat "^" (regexp-quote term) "$") end t))))
+ (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 (ruby-proc))))
+ (set-buffer (marker-buffer m))
+ (goto-char m)
+ (insert ruby-eval-separator "\n")
+ (set-marker m (point))))
(comint-send-string (ruby-proc) (format "eval <<'%s', nil, %S, %d\n" term file line))
(comint-send-region (ruby-proc) start end)
(comint-send-string (ruby-proc) (concat "\n" term "\n"))))