Hi Tony. Of course this was a trivial example. I was grepping the output of jar -> content-texfile to find the packages of a java-class. Currently I'm using this function. I'm invoking this function for up to 40 files or more.. That depends on how many modules I have imported. let type_pattern = '\zs\('.func_name.'\)\%(\s*,\s*\%('.func_name.'\)\)*\ze\s*::' if line =~ type_pattern This is no longer that simple. But I can do a deepcopy and use filter.. But then I'll no longer able to get the line numbers.. My question was meant to be more general as my example given in the last post.
Greetings Marc function! vl#dev#haskell#modules_list_cache_jump#ScanModuleForFunctions(file) " a function is recognized as function if the looks like " a b c = ... " and a is no keyword (data, new\=type, instance) let func_name = '\w\+' let no_f_pattern = '\%(\%(\%(new\)\=type\)\|data\)' " pattern1 / 2 matches " 1) function_name arg1 arg2 = " 2) arg1 `function_name` arg2 = let f_pattern1 = '\zs'.func_name.'\ze\%(\s\+\w\+\)*\s*=' let f_pattern2 = '\w\+\s*`\zs\w\+\ze`\s*\w\+\s*=' let f_pattern = '^\s*\%(\%('.f_pattern1.'\)\|\%('.f_pattern2.'\)\)' let result = {} for line_nr in range(0,len(a:file)-1) let line = a:file[line_nr] if line =~ no_f_pattern continue endif if line =~ f_pattern let result[matchstr(line, f_pattern1)]={"impl": line_nr} endif endfor " add type declarations.. doesn't recognize lists (a, b :: ) yet. " Is needed to get the function names eg of " newtype Cont r a = Cont { runCont :: (a -> r) -> r } let type_pattern = '\zs\('.func_name.'\)\%(\s*,\s*\%('.func_name.'\)\)*\ze\s*::' let g:tp = type_pattern for line_nr in range(0,len(a:file)-1) let line = a:file[line_nr] if line =~ type_pattern let list = split(matchstr(line, type_pattern),'\s*,\s*') for func_name in list if exists("result['".func_name."']") let result[func_name]['type'] = line_nr else let result[func_name]={"type": line_nr} endif endfor endif endfor return result endfunction