Stop checking settings during source
This patch removes the need of having g:qcc_query_command set to anything prior to loading QueryCommandComplete.
- Id
- 14791f2d19d77b0887057e82e21e7934bc39103b
- Author
- Caio
- Commit time
- 2013-06-17T22:03:48+02:00
Modified plugin/querycommandcomplete.vim
return result
endfunction
-" Try to use mutt's query_command by default if nothing is set
-if empty(s:GetSetting('query_command'))
- let s:querycmd = system('mutt -Q query_command 2>/dev/null')
- let s:querycmd = substitute(s:querycmd, '^query_command="\(.*\)"\n', '\1','')
-
- if len(s:querycmd)
- let g:qcc_query_command = s:querycmd
- let g:qcc_multiline = 1
- autocmd FileType mail setlocal omnifunc=QueryCommandComplete
- else
- echoerr "QueryCommandComplete: g:qcc_query_command not set!"
- finish
- endif
-endif
-
let g:loaded_QueryCommandComplete = 1
let s:save_cpo = &cpo
set cpo&vim
return s:ShouldGenerateCompletions(a:line_number - 1)
endfunction
+function! s:CheckSettings()
+ " Try to use mutt's query_command by default if nothing is set
+ if empty(s:GetSetting('query_command'))
+ let s:querycmd = system('mutt -Q query_command 2>/dev/null')
+ let s:querycmd = substitute(s:querycmd, '^query_command="\(.*\)"\n', '\1','')
+
+ if len(s:querycmd)
+ let g:qcc_query_command = s:querycmd
+ let g:qcc_multiline = 1
+ autocmd FileType mail setlocal omnifunc=QueryCommandComplete
+ else
+ echoerr "QueryCommandComplete: g:qcc_query_command not set!"
+ return 0
+ endif
+ endif
+ return 1
+endfunction
+
function! QueryCommandComplete(findstart, base)
- if s:ShouldGenerateCompletions(line('.'))
+ if s:CheckSettings() && s:ShouldGenerateCompletions(line('.'))
return s:GenerateCompletions(a:findstart, a:base)
endif
endfunction