PATCH: determine word to be completed like Readline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PATCH: determine word to be completed like Readline

Doug Kearns
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?


Index: autoload/rubycomplete.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/autoload/rubycomplete.vim,v
retrieving revision 1.25
diff -u -r1.25 rubycomplete.vim
--- autoload/rubycomplete.vim 7 May 2006 07:48:11 -0000 1.25
+++ autoload/rubycomplete.vim 7 May 2006 11:36:19 -0000
@@ -321,20 +321,10 @@
 
   input = VIM::Buffer.current.line
   cpos = VIM::Window.current.cursor[1] - 1
-  input = input[0..cpos] if cpos != 0
+  input = input[0..cpos]
   input += base
 
-  rip = input.rindex(/\s/,cpos)
-  if rip
-    input = input[rip..input.length]
-  end
-
-  asn = /^.*(\+|\-|\*|=|\(|\[)=?(\s*[A-Za-z0-9_:@.-]*)(\s*(\{|\+|\-|\*|\%|\/)?\s*).*/
-  if asn.match(input)
-    input = $2
-  end
-
-  input.strip!
+  input = input.sub(/.*[ \t\n\"\\'`><=;|&{(]/, '') # Readline.basic_word_break_characters
   message = nil
   receiver = nil
   candidates = []
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: determine word to be completed like Readline

Mark Guzman
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

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: determine word to be completed like Readline

Doug Kearns
On Sun, May 07, 2006 at 05:07:21PM -0400, Mark Guzman wrote:
> Doug Kearns wrote:

<snip>
 
> The readline regex does fix the single element problem, it also breaks
> x=a<C-x><C-o>+b+c.

Yes - an example of some of the improvements we could make to that
pattern.

> 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.

I'm a pedant and a contrary one at that. ;-)
 
> 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.

Is there any reasonable way, ignoring performance issues, to get the
'binding' at the completion point?
 
> The second array clause was a test item left in by me. I've applied the
> patch you sent and removed that array code.

I was thinking of it more as a discussion point. I assume it makes sense
then? ;-)

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: determine word to be completed like Readline

Mark Guzman
Doug Kearns wrote:
> Yes - an example of some of the improvements we could make to that
> pattern.
>
>  
Hopefully irb and VimRegEx will make it happen.
>
> I'm a pedant and a contrary one at that. ;-)
>  
Features and fixes are always good, I just like to have some idea of
priority with them.
>  
>  
>
> Is there any reasonable way, ignoring performance issues, to get the
> 'binding' at the completion point?
>  
I'm not sure right now, I'm wracking my brain over the issue.

> I was thinking of it more as a discussion point. I assume it makes sense
> then? ;-)
>
> Regards,
> Doug
> _______________________________________________
> vim-ruby-devel mailing list
> [hidden email]
> http://rubyforge.org/mailman/listinfo/vim-ruby-devel
>  


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

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: determine word to be completed like Readline

Doug Kearns
On Tue, May 09, 2006 at 04:11:34PM -0400, Mark Guzman wrote:
> Doug Kearns wrote:
> > Yes - an example of some of the improvements we could make to that
> > pattern.
> >
> >  
> Hopefully irb and VimRegEx will make it happen.

Are there any other regressions resulting from this 'new' pattern? I
haven't noticed any...

> > I'm a pedant and a contrary one at that. ;-)
> >  
> Features and fixes are always good, I just like to have some idea of
> priority with them.

You're the boss man. ;-)

<snip>
 
Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel