I’ve been playing with the Readline module for the last hours and i’d
like to make a few suggestions:
In the documenation from current CVS[1], it says that completion proc
is a Proc object that should take a string as input parameter.
In fact and contrary to what I thought would be more logical, this object
only receives the last “part of word” typed by the user ie if I type “cd
pro” and then press , i receive “pro” but not the "cd " string
before. As this is used to guess what completion we should offer to the
user, I thought it would be better for the Proc object to also receive
this part of the input (if I know my user is going to cd to somewhere, I
can complete only on matching folders for example).
so completion_proc would be
Readline.complretion_proc = Proc.new{ |last_word, beginning| … }
with last_word being “pro” and beginning "cd " in my example.
Maybe this mail should have been directed to ruby-core. It’s not clear
yet in my mind what belongs to -talk and what belongs to -core.
Let me know if this is some kind of possible enhancement
My ruby is:
% ruby -v
ruby 1.6.7 (2002-03-19) [i386-linux]
following this thread, i’ve written a quick patch for readline.c which
allows the Proc object to receive a new supplementaty variable which
contains the current buffer for the input line:
This patch breaks backward compatibility with previous scripts using
Readline but allows greater flexibility concerning the use of Readline
in general.
I don’t know what is the best way to submit a patch, so please let me
know if there is a more formal way. If any guru (Matz, maybe ?!) has a
look at my patch, I’ll be glad to hear your comments. If you are not a
guru, comment anyway, i’d love some feedback!