From: nobu.nakada@... Date: 2002-08-15T15:35:31+09:00 Subject: [ruby-dev:18018] Re: inferior-ruby-mode and irb なかだです。 At Thu, 15 Aug 2002 14:27:00 +0900, Nobuyoshi-Nakada wrote: > > |ヒアドキュメントだとどうでしょうか。 > > > > irbのレクサはヒアドキュメントに対応してないんじゃなかったっ > > けか。 > > 完全じゃないのかも知れませんが、少なくともこの話に関しては充分 > そうです。 とりあえずこんなところで。terminatorの生成はもうちょっとマシな 方法があるかも知れませんが。 Index: inf-ruby.el =================================================================== RCS file: /cvs/ruby/src/ruby/misc/inf-ruby.el,v retrieving revision 1.4 diff -u -2 -p -r1.4 inf-ruby.el --- inf-ruby.el 29 Jan 2002 07:16:09 -0000 1.4 +++ inf-ruby.el 15 Aug 2002 06:33:16 -0000 @@ -243,9 +243,21 @@ of `ruby-program-name'). Runs the hooks (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 () -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦