PATCH: determine word to be completed like Readline

Mark Guzman segfault at hasno.info
Sun May 7 17:07:21 EDT 2006


Doug Kearns wrote:
> Mark,
>
> I was having some problems completing single element array literals:
>
> [a].<C-x><C-o> # we need a shorthand for the completion point
>
> This was being fed to the completion case expression as "a." rather
> than "[a].".
>
> Excuse me if I'm overlooking some obvious issues; I've only just started
> to have a look at your script now. ;-) But I was wondering if it would
> be better to keep rubycomplete.vim closer to irb/completion.rb?
>
> For example, is there a reason we couldn't simplify determining the word
> to be completed by feeding get_completions(), essentially the irb
> readline completion proc, _exactly_ the same input that it would be
> receiving from Readline in irb? (See patch below.) Then, as
> rubycomplete.vim is improved, we could, very simply, feed those
> improvements back into irb/complete.rb and vice versa?
>
> You've added Range literal completion which should be included in irb
> and I can also see some simple improvements we could make to the
> Readline.basic_word_break_characters pattern.
>
> Would this cost us anything in terms of functionality?
>
> I guess the ultimate solution would be to find a way to use
> IRB::InputCompletor::CompletionProc directly...
>
> Regards,
> Doug
>
> PS. Why are there two when clauses for Array?
>
>
>   
The readline regex does fix the single element problem, it also breaks
x=a<C-x><C-o>+b+c.
I generally put spacing in my code, so I'm not worried about x=a+b+c,
but it was an item you raised earlier.

As far as using irb/complete.rb directly, I think there are a good
number of differences precluding that. Its possible,
but I'm not sure there would be much benefit. The actual method list
evaluation code in complete.rb would have to be rethought.
Classloading would have to be rethought amongst other things. I'm all
for providing patches to complete.rb, but I don't see
complete.rb going the same place. I'd like to add some more information
to what we put in the dictionary, along with variable completion.

The second array clause was a test item left in by me. I've applied the
patch you sent and removed that array code.
  --mark



-- 
sic transit gloria et adulescentia 
blog | http://blog.hasno.info/blog
wiki | http://wiki.hasno.info



More information about the vim-ruby-devel mailing list