Re: Using tags to quick complete funtion names

2006-06-25 Thread Hari Krishna Dara

On Sat, 24 Jun 2006 at 7:12pm, Marc Weber wrote:

 Hi.
 I'm tired of writing things like
 getBlahFoo
 using getBc-xc-t is fine, but why type et?

 That's why I've written this complete function:
 Now you can type BFm-x to expand it to getBlahFoo
 it uses the created regexpr B.*F.* to filter all tags
 = start


 set completefunc=CompleteWithSimpleRegex
 inoremap m-x c-rcall DoCompleteRegex()cr


  eg use mnmapping to match main
  or CFmappnig to match CompleteFunction
 fun! CompleteWithSimpleRegex(findstart, base)
   if a:findstart
  locate the start of the word
 let line = getline('.')
 let start = col('.') - 1
 while start  0  line[start - 1] =~ '\a'
   let start -= 1
 endwhile
 return start
   else
 let pattern = substitute(a:base,'\(.\)','\1.*','')
 let list = taglist(pattern)
 let res = []
 for p in list
   call add(res, p['name'])
 endfor
 let g:res=res
 return res
   endif
 endfun
 = end
==

 Now I'd like to set the complete func only temporarely because I might
 define another later.

 I did try this to store the complete func and restore it after
 c-xc-u
   fun DoCompleteRegex()
 let cf = completefunc
 set completefunc=CompleteWithSimpleRegex
 normal c-xc-u
 set completefunc=cf
 return 
   endfun
 It didn't work.

 How would you do this?

 Marc

I don't know why the normal command wouldn't work in your case, but you
could try to set the completion results immediately by calling the
complete() function, instead of fiddling with 'completefunc'.

-- 
HTH,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Using tags to quick complete funtion names

2006-06-25 Thread Gerald Lai

On Sat, 24 Jun 2006, Hari Krishna Dara wrote:

[snip]

I did try this to store the complete func and restore it after
c-xc-u
fun DoCompleteRegex()
  let cf = completefunc
  set completefunc=CompleteWithSimpleRegex
  normal c-xc-u
  set completefunc=cf
  return 
endfun
It didn't work.

How would you do this?

Marc


I don't know why the normal command wouldn't work in your case, but you
could try to set the completion results immediately by calling the
complete() function, instead of fiddling with 'completefunc'.


Try

  exe normal \C-x\C-u

instead.

--
Gerald


Re: Using tags to quick complete funtion names

2006-06-24 Thread Marc Weber

Here is a enhanced regular expression which is more useful

 this is tricky, either , or or lower to Upper change or Upper Upper
 lower will trigger inserting .*
 you type - regex to match tags
 inP - in.*P
 Aab - Aab
 ABab - AB.*ab
 A,ab - A.*ab
let pattern = 
'^'.substitute(a:base,',\|\U\zs\ze\u\|\u\u\zs\ze\U','\1.*','g')

vim is cool, eh?
I still don't know how to make this work with c-xc-i? Any idea?
Perhaps getting a list by yourself.. matching the words of the buffer.

This would be a nice vim tip, wouldn't it?

Marc