Takeshi NISHIDA avatar Takeshi NISHIDA committed 9727c89

introduced l9

Comments (0)

Files changed (2)

 endfunction
 
 "
-function s:setTempOption(group, name, value)
-  call extend(s:tempOptionSet[a:group], { a:name : eval('&' . a:name) }, 'keep')
-  execute printf('let &%s = a:value', a:name)
-endfunction
-
-"
-function s:restoreTempOptions(group)
-  for [name, value] in items(s:tempOptionSet[a:group])
-    execute printf('let &%s = value', name)
-  endfor
-  let s:tempOptionSet[a:group] = {}
-endfunction
-
-"
 function s:getCurrentWord()
   return matchstr(s:getCurrentText(), '\k*$')
 endfunction
   " popup menu is visible, another popup is not available unless input <C-e>
   " or try popup once. So first completion is duplicated.
   call insert(s:behavsCurrent, s:behavsCurrent[s:iBehavs])
-  call s:setTempOption(s:GROUP0, 'spell', 0)
-  call s:setTempOption(s:GROUP0, 'completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
-  call s:setTempOption(s:GROUP0, 'complete', g:acp_completeOption)
-  call s:setTempOption(s:GROUP0, 'ignorecase', g:acp_ignorecaseOption)
+  call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
+        \ '&spell', 0)
+  call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
+        \ '&completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
+  call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
+        \ '&complete', g:acp_completeOption)
+  call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
+        \ '&ignorecase', g:acp_ignorecaseOption)
   " NOTE: With CursorMovedI driven, Set 'lazyredraw' to avoid flickering.
   "       With Mapping driven, set 'nolazyredraw' to make a popup menu visible.
-  call s:setTempOption(s:GROUP0, 'lazyredraw', !g:acp_mappingDriven)
+  call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
+        \ '&lazyredraw', !g:acp_mappingDriven)
   " NOTE: 'textwidth' must be restored after <C-e>.
-  call s:setTempOption(s:GROUP1, 'textwidth', 0)
+  call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP1,
+        \ '&textwidth', 0)
   call s:setCompletefunc()
   call feedkeys(s:behavsCurrent[s:iBehavs].command . "\<C-r>=acp#onPopupPost()\<CR>", 'n')
   return '' " this function is called by <C-r>=
   inoremap <C-h> <Nop> | iunmap <C-h>
   inoremap <BS>  <Nop> | iunmap <BS>
   let s:behavsCurrent = []
-  call s:restoreTempOptions(s:GROUP0)
+  call l9#tempvariables#end(s:TEMP_VARIABLES_GROUP0)
   if a:fGroup1
-    call s:restoreTempOptions(s:GROUP1)
+    call l9#tempvariables#end(s:TEMP_VARIABLES_GROUP1)
   endif
 endfunction
 
 "
 function s:setCompletefunc()
   if exists('s:behavsCurrent[s:iBehavs].completefunc')
-    call s:setTempOption(0, 'completefunc', s:behavsCurrent[s:iBehavs].completefunc)
+    call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
+          \ '&completefunc', s:behavsCurrent[s:iBehavs].completefunc)
   endif
 endfunction
 
 "=============================================================================
 " INITIALIZATION {{{1
 
-let s:GROUP0 = 0
-let s:GROUP1 = 1
+let s:TEMP_VARIABLES_GROUP0 = "AutoComplPop0"
+let s:TEMP_VARIABLES_GROUP1 = "AutoComplPop1"
 let s:lockCount = 0
 let s:behavsCurrent = []
 let s:iBehavs = 0
-let s:tempOptionSet = [{}, {}]
 let s:snipItems = {}
 
 " }}}1
 "=============================================================================
 " LOAD GUARD {{{1
 
+let s:VERSION_VIM = 702
+let s:VERSION_L9 = 00.0100
 if exists('g:loaded_acp')
   finish
-elseif v:version < 702
-  echoerr 'AutoComplPop does not support this version of vim (' . v:version . ').'
+elseif v:version < s:VERSION_VIM
+  echoerr 'AutoComplPop requires Vim version ' . s:VERSION_VIM
+  finish
+elseif !exists('*l9#isCompatible') || !l9#isCompatible(s:VERSION_L9)
+  echoerr 'AutoComplPop requires l9 library version ' . s:VERSION_L9
   finish
 endif
 let g:loaded_acp = 1
 " FUNCTION: {{{1
 
 "
-function s:defineOption(name, default)
-  if !exists(a:name)
-    let {a:name} = a:default
-  endif
-endfunction
-
-"
 function s:makeDefaultBehavior()
   let behavs = {
         \   '*'      : [],
 " INITIALIZATION {{{1
 
 "-----------------------------------------------------------------------------
-call s:defineOption('g:acp_enableAtStartup', 1)
-call s:defineOption('g:acp_mappingDriven', 0)
-call s:defineOption('g:acp_ignorecaseOption', 1)
-call s:defineOption('g:acp_completeOption', '.,w,b,k')
-call s:defineOption('g:acp_completeoptPreview', 0)
-call s:defineOption('g:acp_behaviorUserDefinedFunction', '')
-call s:defineOption('g:acp_behaviorUserDefinedMeets', '')
-call s:defineOption('g:acp_behaviorSnipmateLength', -1)
-call s:defineOption('g:acp_behaviorKeywordCommand', "\<C-n>")
-call s:defineOption('g:acp_behaviorKeywordLength', 2)
-call s:defineOption('g:acp_behaviorKeywordIgnores', [])
-call s:defineOption('g:acp_behaviorFileLength', 0)
-call s:defineOption('g:acp_behaviorRubyOmniMethodLength', 0)
-call s:defineOption('g:acp_behaviorRubyOmniSymbolLength', 1)
-call s:defineOption('g:acp_behaviorPythonOmniLength', 0)
-call s:defineOption('g:acp_behaviorPerlOmniLength', -1)
-call s:defineOption('g:acp_behaviorXmlOmniLength', 0)
-call s:defineOption('g:acp_behaviorHtmlOmniLength', 0)
-call s:defineOption('g:acp_behaviorCssOmniPropertyLength', 1)
-call s:defineOption('g:acp_behaviorCssOmniValueLength', 0)
-call s:defineOption('g:acp_behavior', {})
+call l9#defineVariableDefault('g:acp_enableAtStartup', 1)
+call l9#defineVariableDefault('g:acp_mappingDriven', 0)
+call l9#defineVariableDefault('g:acp_ignorecaseOption', 1)
+call l9#defineVariableDefault('g:acp_completeOption', '.,w,b,k')
+call l9#defineVariableDefault('g:acp_completeoptPreview', 0)
+call l9#defineVariableDefault('g:acp_behaviorUserDefinedFunction', '')
+call l9#defineVariableDefault('g:acp_behaviorUserDefinedMeets', '')
+call l9#defineVariableDefault('g:acp_behaviorSnipmateLength', -1)
+call l9#defineVariableDefault('g:acp_behaviorKeywordCommand', "\<C-n>")
+call l9#defineVariableDefault('g:acp_behaviorKeywordLength', 2)
+call l9#defineVariableDefault('g:acp_behaviorKeywordIgnores', [])
+call l9#defineVariableDefault('g:acp_behaviorFileLength', 0)
+call l9#defineVariableDefault('g:acp_behaviorRubyOmniMethodLength', 0)
+call l9#defineVariableDefault('g:acp_behaviorRubyOmniSymbolLength', 1)
+call l9#defineVariableDefault('g:acp_behaviorPythonOmniLength', 0)
+call l9#defineVariableDefault('g:acp_behaviorPerlOmniLength', -1)
+call l9#defineVariableDefault('g:acp_behaviorXmlOmniLength', 0)
+call l9#defineVariableDefault('g:acp_behaviorHtmlOmniLength', 0)
+call l9#defineVariableDefault('g:acp_behaviorCssOmniPropertyLength', 1)
+call l9#defineVariableDefault('g:acp_behaviorCssOmniValueLength', 0)
+call l9#defineVariableDefault('g:acp_behavior', {})
 "-----------------------------------------------------------------------------
 call extend(g:acp_behavior, s:makeDefaultBehavior(), 'keep')
 "-----------------------------------------------------------------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.