Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > readline tab completion -- the whole line?

Thread Tools

readline tab completion -- the whole line?

Posts: n/a
Recently, a thread about tab completion showed me
Readline.completion_proc = Proc new {|prefix| ... }

and while that is an improvement for my little apps, I wonder whether the
block can get more than the current word on the line, i.e.
little> save lo[TAB]
gives me the prefix (passed as param to the block) "lo", not e.g. "save lo"
or ["save", "lo"] so basically I can not use the context in a nice way (use
"localfile" in this case, not "load").

I figured I can do
Readline.basic_word_break_characters = ""
after which I get the entire line (which I can then #split by hand).

Am I missing something? Is readline (despite its weight) so primitive?

Reply With Quote
Daniel Calvelo
Posts: n/a
Currently, completion_proc seems to only be able to handle the current
"word" being processed. You could hack basic_word_break_characters so
that the whole line is fed into completion_proc, and do any string
massaging in there, as you stated.

There is somewhere in the ruby-talk archives a patch to have a
two-argument version of completion_proc, but it doesn't seem to have
gotten to the official distribution. It would have given both the
current line and the current word.

So yes, I guess your last judgment isn't completely wrong.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to indent blocks when readline completion is on? Steven D'Aprano Python 1 11-13-2011 02:40 PM
Ruby readline - completion based on already-entered commands Bill Atkins Ruby 6 08-11-2005 04:46 PM
Inserting a tab with tab completion enabled on win32 News Sympatico Python 0 05-21-2005 03:36 AM
Spelling Completion or Code completion in ASP? ziggs ASP General 2 04-21-2004 02:02 PM
context-sensitive completion using readline.set_completer Edvard Majakari Python 0 11-18-2003 08:28 AM