1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-08-19 10:07:06 +00:00
parent e7b7d28b65
commit e0c5eed65c
2 changed files with 71 additions and 7 deletions

View file

@ -1,3 +1,16 @@
Mon Aug 19 19:01:55 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* 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.
Mon Aug 19 15:38:44 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (sort_2): comparison should be done as signed long.

View file

@ -35,13 +35,25 @@
;;; HISTORY
;;; senda - 8 Apr 1998: Created.
;;; $Log$
;;; 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]
;;;
;;;
;;; * file.c (rb_stat_rdev_minor): added. [new]
;;;
;;;
;;; * file.c (rb_stat_inspect): print mode in octal.
;;;
;;;
;;; Revision 1.3 1999/12/01 09:24:18 matz
;;; 19991201
;;;
@ -77,6 +89,7 @@
;;;
(require 'comint)
(require 'compile)
(require 'ruby-mode)
;;
@ -109,6 +122,11 @@
(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)
(cond ((not inferior-ruby-mode-map)
(setq inferior-ruby-mode-map
(copy-keymap comint-mode-map))
@ -122,8 +140,10 @@
"Set local key defs for inf-ruby in ruby-mode"
(define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
; (define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
(define-key ruby-mode-map "\C-c\C-e" 'ruby-send-definition)
(define-key ruby-mode-map "\C-c\M-e" 'ruby-send-definition-and-go)
(define-key ruby-mode-map "\C-c\C-b" 'ruby-send-block)
(define-key ruby-mode-map "\C-c\M-b" 'ruby-send-block-and-go)
(define-key ruby-mode-map "\C-c\C-x" 'ruby-send-definition)
(define-key ruby-mode-map "\C-c\M-x" 'ruby-send-definition-and-go)
(define-key ruby-mode-map "\C-c\C-r" 'ruby-send-region)
(define-key ruby-mode-map "\C-c\M-r" 'ruby-send-region-and-go)
(define-key ruby-mode-map "\C-c\C-z" 'switch-to-ruby)
@ -180,6 +200,8 @@ 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)
(run-hooks 'inferior-ruby-mode-hook))
(defvar inferior-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
@ -242,11 +264,23 @@ of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
(setq ruby-buffer "*ruby*")
(pop-to-buffer "*ruby*"))
(defconst ruby-send-terminator "--inf-ruby-%x-%d-%d-%d--"
"Template for irb here document terminator.
Must not contain ruby meta characters.")
(defun ruby-send-region (start end)
"Send the current region to the inferior Ruby process."
(interactive "r")
(comint-send-region (ruby-proc) start end)
(comint-send-string (ruby-proc) "\n"))
(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))))
(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"))))
(defun ruby-send-definition ()
"Send the current definition to the inferior Ruby process."
@ -262,6 +296,16 @@ of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
; (interactive)
; (ruby-send-region (save-excursion (backward-sexp) (point)) (point)))
(defun ruby-send-block ()
"Send the current block to the inferior Ruby process."
(interactive)
(save-excursion
(ruby-end-of-block)
(end-of-line)
(let ((end (point)))
(ruby-beginning-of-block)
(ruby-send-region (point) end))))
(defun switch-to-ruby (eob-p)
"Switch to the ruby process buffer.
With argument, positions cursor at end of buffer."
@ -287,6 +331,13 @@ Then switch to the process buffer."
(ruby-send-definition)
(switch-to-ruby t))
(defun ruby-send-block-and-go ()
"Send the current block to the inferior Ruby.
Then switch to the process buffer."
(interactive)
(ruby-send-block)
(switch-to-ruby t))
(defvar ruby-source-modes '(ruby-mode)
"*Used to determine if a buffer contains Ruby source code.
If it's loaded into a buffer that is in one of these major modes, it's