pass vim argument in completefunc
Question: I am writing a `vimscript` that uses `completefunc` as:

    
    
    " GetComp: Menu and Sunroutine Completion {{{1
    function! GetComp(arg, 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
        echomsg '**** completing' a:base
    python << EOF
    import vim
    import os
    flsts = [' ']
    
    path = "."
    for dirs, subdirs, files in os.walk(path):
        for tfile in files:
            if tfile.endswith(('f90', 'F90', 'f', 'F')):
                ofile = open(dirs+'/'+tfile)
                for line in ofile:
                    if line.lower().strip().startswith(vim.eval("a:arg")):
                        modname = line.split()[1]
                        flsts.append(modname)
    vim.command("let flstsI = %s"%flsts)                    
    EOF
    if eval("a:arg") = "module"
      for m in ["ieee_arithmatic", "ieee_exceptions", "ieee_features", "iso_c_bindings", "iso_fortran_env",  "omp_lib", "omp_lib_kinds"]
        if m =~ "^" . a:base
          call add(flstsI, m)
        endif
      endfor
    elseif eval("a:arg") = "subroutine"
    for m in ["alarm()", "date_and_time()", "backtrace", "c_f_procpointer()", "chdir()", "chmod()", "co_broadcast()", "get_command()", "get_command_argument()", "get_environment_variable()", "mvbits()", "random_number()", "random_seed()"]
      if m =~ "^" . a:base
        call add(flstsI, m)
      endif
    endfor
    endif
    
    return flstsI
    endif
    endfunction
    

I will call it for 2 different argument as:

    
    
    inoremap <leader>call  call <C-o>:set completefunc=GetComp("subroutine", findstart, base)<CR><C-x><C-u>
    inoremap <leader>use  use <C-o>:set completefunc=GetComp("module", findstart, base)<CR><C-x><C-u>
    

But trying so, gives error: `Unknown function GetComp(`

I don't know how to call them. If I don't use `arg`, then, using this
[reply](http://stackoverflow.com/questions/34745939/vim-update-complete-popup-
as-i-type/34747283#34747283), I can call this perfectly. Kindly help.


Answer: You'll have to attach a context to your completion. If you look closely at [my
message on vi.se](http://vi.stackexchange.com/questions/5820/dynamic-
completion), you'll see a framework that permits to bind data to a user-
completion. From there in your mapping, it just becomes a question of which
context to attach.

A simplified way would be to execute a (preparation) function from the
mappings and have the function set script global variables that will be used
in your completion function.

