From: shugo@... (=?ISO-2022-JP?B?GyRCQTBFRBsoQiAbJEI9JDhjGyhC?= / maeda shugo) Date: 1997-08-21T14:14:54+09:00 Subject: [ruby-list:3746] Re: module for GNU Readline Library 前田です。 In message "[ruby-list:3736] module for GNU Readline Library" 前田 修吾 / maeda shugo wrote: |アーカイブにはサンプルとしてeval.rbの拡張版のrubyshという |スクリプトが入っています。 未入力時の補完があまりに遅いのでちょっと手を加えました。 以下のパッチをあててください。 -- 前田 修吾 diff -u -r1.1 rubysh --- rubysh 1997/08/20 15:20:41 1.1 +++ rubysh 1997/08/20 16:30:40 @@ -17,24 +17,12 @@ PS2 = "ruby| " KEYWORDS = [ - "end", - "class", "module", - "def", "undef", - "return", - "if", "unless", "else", "elsif", "then", - "not", "and", "or", - "raise", "fail", - "while", "loop", - "for", "in", - "case", "when", - "self", "super", "nil", - "alias", - "until", - "begin", "ensure", "rescue", - "do", "yield", - "break", "next", "continue", "retry", "redo", - "include", - "load", "require", "autoload" + "end", "class", "module", "def", "undef", + "return", "if", "unless", "else", "elsif", "then", + "not", "and", "or", "while", "loop", "for", "in", + "case", "when", "self", "super", "nil", "alias", + "until", "begin", "ensure", "rescue", "do", "yield", + "include" ] CLASSES = [ @@ -59,7 +47,8 @@ "raise", "rand", "readline", "readlines", "require", "redo", "retry", "select", "sleep", "split", "sprintf", "srand", "sub", "sub!", "syscall", "system", "test", - "trace_var", "trap", "ungetc", "untrace_var" + "trace_var", "trap", "ungetc", "untrace_var", + "continue", "fail" ] COMPLETION_ENTRIES = KEYWORDS | CLASSES | FUNCTIONS @@ -69,9 +58,13 @@ @prompt = PS1 @indent = 0 set_completion_proc { |str| - exp = Regexp.new("^" + str) - COMPLETION_ENTRIES.find_all do |word| - word =~ exp + if str == "" + COMPLETION_ENTRIES + else + exp = Regexp.new("^" + str) + COMPLETION_ENTRIES.find_all do |word| + word =~ exp + end end }