# Readline tab completion -- the whole line?

**URL:** <https://www.ruby-forum.com/t/readline-tab-completion-the-whole-line/51439>\
**Category:** Ruby\
**Created:** [December 31, 2005, 12:06pm UTC](https://www.ruby-forum.com/t/readline-tab-completion-the-whole-line/51439 "2005-12-31T12:06:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 31, 2005, 12:06pm UTC](https://www.ruby-forum.com/t/readline-tab-completion-the-whole-line/51439/1 "2005-12-31T12:06:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 31, 2005, 12:09pm UTC](https://www.ruby-forum.com/t/readline-tab-completion-the-whole-line/51439/2 "2005-12-31T12:09:02Z")

</div>

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
