Update of /cvsroot/vim-latex/vimfiles/plugin
In directory sc8-pr-cvs1:/tmp/cvs-serv9901
Modified Files:
imaps.vim
Log Message:
Bug: iabs break when latex-suite is triggered.
(Preben Randhol, Sanip P Deshmukh)
Cause: If a mapping ends in a letter (say '\'), then abbreviations are not
triggered by that letter. For example, if we have
imap \ <C-r>='\'<CR>
iab 12 twelve
Then typing 12\ doesn't expand to twelve\.
(Strangely enough "imap \ ?" doesn't have this problem and we get
twelve?. Vim bug?)
This problem is aggravated by the fact that latex-suite "protects"
most letters to avoid expansions such as ``2 -> `\sqrt{}
Solution: After checking for mappings ending in a letter, if that letter is
not in 'iskeyword', then also check whether the previous word has
an abbreviation. Since vim does not have the equivalent of
mapcheck() for abbreviations, this is complicated (maybe even hacky).
Index: imaps.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** imaps.vim 5 Feb 2003 04:12:28 -0000 1.28
--- imaps.vim 5 Feb 2003 23:29:04 -0000 1.29
***************
*** 227,236 ****
let ft = ""
else
! return a:char
endif
" Find the longest left-hand side that matches the line so far.
" matchstr() returns the match that starts first. This automatically
" ensures that the longest LHS is used for the mapping.
! let lhs = matchstr(text, '\V\(' . s:LHS_{ft}_{charHash} . '\)\$')
if strlen(lhs) == 0
return a:char
--- 227,268 ----
let ft = ""
else
! " If this is a character which could have been used to trigger an
! " abbreviation, check if an abbreviation exists.
! if a:char !~ '\k'
! let lastword = matchstr(getline('.'), '\k\+$', '')
! if lastword != ''
! " An extremeley wierd way to get around the fact that vim
! " doesn't have the equivalent of the :mapcheck() function for
! " abbreviations.
! exec "redir @a | silent! iab ".lastword." | redir END"
! if @a =~ "No abbreviation found"
! return a:char
! endif
! let abbreviationRHS = matchstr(@a, "\n".'i\s\+\k\+\s\+@\?\zs.*')
! let abbreviationRHS = escape(abbreviationRHS, '<')
! exec 'let abbreviationRHS = "'.abbreviationRHS.'"'
!
! let lhs = lastword.a:char
! let rhs = abbreviationRHS.a:char
! let phs = IMAP_GetPlaceHolderStart()
! let phe = IMAP_GetPlaceHolderEnd()
! else
! return a:char
! endif
! else
! return a:char
! endif
endif
" Find the longest left-hand side that matches the line so far.
" matchstr() returns the match that starts first. This automatically
" ensures that the longest LHS is used for the mapping.
! if !exists('lhs') || !exists('rhs')
! let lhs = matchstr(text, '\V\(' . s:LHS_{ft}_{charHash} . '\)\$')
! let hash = s:Hash(lhs)
! let rhs = s:Map_{ft}_{hash}
! let phs = s:phs_{ft}_{hash}
! let phe = s:phe_{ft}_{hash}
! endif
!
if strlen(lhs) == 0
return a:char
***************
*** 239,245 ****
" character typed:
let bs = substitute(strpart(lhs, 1), ".", "\<bs>", "g")
! let hash = s:Hash(lhs)
! return bs . IMAP_PutTextWithMovement(s:Map_{ft}_{hash},
! \ s:phs_{ft}_{hash}, s:phe_{ft}_{hash})
endfunction
--- 271,275 ----
" character typed:
let bs = substitute(strpart(lhs, 1), ".", "\<bs>", "g")
! return bs . IMAP_PutTextWithMovement(rhs, phs, phe)
endfunction
***************
*** 682,686 ****
endif
endfunction " }}}
! " IMAP_DebugClear: interface to Tex_DebugClear if avaialable, otherwise emulate it {{{
" Description:
function! IMAP_DebugPrint(pattern)
--- 712,716 ----
endif
endfunction " }}}
! " IMAP_DebugPrint: interface to Tex_DebugPrint if avaialable, otherwise emulate it {{{
" Description:
function! IMAP_DebugPrint(pattern)
|