Hi.
I'm tired of writing things like
getBlahFoo
using getB<c-x><c-t> is fine, but why type "et"?

That's why I've written this complete function:
Now you can type BF<m-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-r>call DoCompleteRegex()<cr>


" eg use mn<mapping> to match main
" or CF<mappnig 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-x><c-u>
        fun DoCompleteRegex()
          let cf = &completefunc
          set completefunc=CompleteWithSimpleRegex
          normal <c-x><c-u>
          set completefunc=cf
          return ""
        endfun
It didn't work.

How would you do this?

Marc

Reply via email to