Skip to content

Instantly share code, notes, and snippets.

@kana
Created April 9, 2010 14:34
Show Gist options
  • Save kana/361221 to your computer and use it in GitHub Desktop.
Save kana/361221 to your computer and use it in GitHub Desktop.
--- xmlcomplete.vim.orig 2010-04-09 22:27:24.000000000 +0900
+++ xmlcomplete.vim 2010-04-09 22:28:07.000000000 +0900
@@ -475,12 +475,12 @@
endfunction
function! s:SetKeywords()
- let g:IsKeywordBak=&iskeyword
- let &iskeyword='33-255'
+ let s:IsKeywordBak=&l:iskeyword
+ let &l:iskeyword='33-255'
endfunction
function! s:RestoreKeywords()
- let &iskeyword=g:IsKeywordBak
+ let &l:iskeyword=s:IsKeywordBak
endfunction
function! s:Push(el, sname)
@kana
Copy link
Author

kana commented Apr 9, 2010

For example, s:Instack() in xmlcomplete.vim is defined as follows:

function! s:Instack(el, sname)
        exe 'let stack='.a:sname            " (1)
        call s:SetKeywords()                " (2)
        let m=match(stack, '\<'.a:el.'\>')
        call s:RestoreKeywords()            " (3)
        ...

After executing s:Instack(), the global value of 'iskeyword' (&g:iskeyword), the local value of 'iskeyword' (&l:iskeyword) and g:IsKeywordBack are changed as follows:

Step | &g:iskeyword    | &l:iskeyword    | g:IsKeywordBack
-----+-----------------+-----------------+----------------
(1)  | [some value]    | [another value] | N/A
(2)  | 33-255          | 33-255          | [another value]
(3)  | [another value] | [another value] | [another value]

This overwriting is very annoying; whenever a new buffer is created and 'iskeyword' for the new buffer is not configured explicitly, the global value of 'iskeyword' will be used. If user opens a new buffer after completion with xmlcomplete.vim, the global value of 'iskeyword' is silently replaced with a value for XML. So that 'iskeyword'-sensitive operations such as *, #, etc don't work as user expects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment