From: Gyoung-Yoon Noh Date: 2005-10-28T06:06:00+09:00 Subject: Re: Ruby readline - completion based on already-entered commands Oops, I misread your question. Sorry for noise. Do you mean argument-specific completion? As far as I know, most readline-based programs tend to parse user input manually. How can it be achived by other language? On 10/28/05, Gyoung-Yoon Noh wrote: > Hi, > > $ cat rlcomp.rb > require "readline" > > nominee = %w[foo bar baz quit] > Readline.completion_proc = > lambda { |s| nominee.find_all { |e| e.match(s) } } > > begin > line = Readline.readline("prompt> ") > puts line > end until line =~ /quit/ > > $ ruby rlcomp.rb > prompt> ba > bar baz > > > HTH. > > On 10/28/05, Matt Wilkins wrote: > > > > hi, > > > > i'm new to ruby, and having the problem Bill Atkins was having with > > the readline library. i searched the archives and found this thread. > > unfortunately no great solution. there was the partial solution from > > Dave Baldwin that involved changing the word split character. as he > > pointed out the real problem is that ruby readline doesn't provide the > > whole line buffer so one cannot do context line completion. > > > > i'm wondering on the follow up process. there is a patch to fix this > > at: > > > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/54796 > > > > it was posted back in nov 2002. but hasn't made it in so far (checked > > 1.8.3), but has been a problem for 3 or 4 years. was the patch no > > good? > > > > thanks for any insight > > > > matt > > > > On 11 Aug 2005, at 15:44, Bill Atkins wrote: > > > How can I use the builtin readline library to complete arguments to > > > commands? I have basic completion working now, so that > > > > > > %wmi > st [TAB] > > > > > > will show valid commands starting with "st" (in this case "start" > > > and "stop"), but how do I complete arguments specific to that > > > command? > > > > > > For instance, if the user has already typed "start Te" and then hits > > > TAB, it should show completions specific to the start command (in > > > this case "TestDevice" and "TerminalServer"), but I'm not clear on > > > how to do this. > > > > > > -- > > > Bill Atkins > > > > > > > > > > > > > -- > http://nohmad.sub-port.net > -- http://nohmad.sub-port.net