Forum: Ruby readline tab completion -- the whole line?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dd54c22454b4e3c21cadf3bdb5192e28?d=identicon&s=25 Kero (Guest)
on 2005-12-31 12:06
(Received via mailing list)
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?

Bye,
Kero.
7da0c2cbd3e9a596006b994b6a36f09c?d=identicon&s=25 Daniel Calvelo (Guest)
on 2005-12-31 12:09
(Received via mailing list)
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.

DCA
This topic is locked and can not be replied to.