[Vim-latex-cvs] vimfiles/plugin imaps.vim,1.10,1.11
Brought to you by:
srinathava,
tmaas
From: <ma...@us...> - 2002-12-22 03:39:08
|
Update of /cvsroot/vim-latex/vimfiles/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv23303 Modified Files: imaps.vim Log Message: This is an attempt to deal with the encoding problems. If it is successful, then IMAP() should work, regardless of the encoding, even when the place holders are funky (i.e., outside the 7-bit ASCII range). Index: imaps.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** imaps.vim 22 Dec 2002 03:01:11 -0000 1.10 --- imaps.vim 22 Dec 2002 03:39:06 -0000 1.11 *************** *** 8,12 **** " while preserving filetype indentation. " ! " Last Change: Fri Dec 20 01:00 AM 2002 PST " " Documentation: {{{ --- 8,12 ---- " while preserving filetype indentation. " ! " Last Change: Sat Dec 21 10:00 PM 2002 EST " " Documentation: {{{ *************** *** 187,190 **** --- 187,210 ---- " }}} + + " IMAP_list: list the rhs and place holders corresponding to a:lhs {{{ + " + " Added mainly for debugging purposes, but maybe worth keeping. + fun! IMAP_list(lhs) + let char = a:lhs[strlen(a:lhs)-1] + let charHash = s:Hash(char) + if exists("s:LHS_" . &ft . "_" . charHash) + let ft = &ft + elseif exists("s:LHS__" . charHash) + let ft = "" + else + return "" + endif + let hash = s:Hash(a:lhs) + return "rhs = " . s:Map_{ft}_{hash} . " place holders = " . + \ s:phs_{ft}_{hash} . " and " . s:phe_{ft}_{hash} + endfun + " }}} + " LookupCharacter: inserts mapping corresponding to this character {{{ " *************** *** 245,253 **** let text = a:str - " If there are no place holders, just return the text. - if text !~ '\V'.phs.'\.\{-}'.phe - return text - endif - " The user's placeholder settings. let phsUser = s:PlaceHolderStart() --- 265,268 ---- *************** *** 255,272 **** " A very rare string: Do not use any special characters here. This is used ! " for moving to the beginning of the inserted text let marker = '<!--- @#% Start Here @#% ----!>' let markerLength = strlen(marker) " If the user does not want to use place-holders, then remove all but the ! " first placeholder if exists('g:Imap_UsePlaceHolders') && !g:Imap_UsePlaceHolders " a heavy-handed way to just use the first placeholder and remove the " rest. Replace the first placeholder with phe ... ! let text = substitute(text, '\V'.phs.'\.\{-}'.phe, phe, '') " ... delete all the others ... ! let text = substitute(text, '\V'.phs.'\.\{-}'.phe, '', 'g') " ... and replace the first phe with phsUser.pheUser . ! let text = substitute(text, '\V'.phe, phsUser.pheUser, '') endif --- 270,302 ---- " A very rare string: Do not use any special characters here. This is used ! " for moving to the beginning of the inserted text. let marker = '<!--- @#% Start Here @#% ----!>' let markerLength = strlen(marker) + " Problem: depending on the setting of the 'encoding' option, a character + " such as "\xab" may not match itself. We try to get around this by + " changing the encoding of all our strings. At the end, we have to + " convert back. + let textEnc = iconv(text, "latin1", &enc) + let phsEnc = iconv(phs, "latin1", &enc) + let pheEnc = iconv(phe, "latin1", &enc) + let phsUserEnc = iconv(phsUser, "latin1", &enc) + let pheUserEnc = iconv(pheUser, "latin1", &enc) + + " If there are no place holders, just return the text. + if textEnc !~ '\V'.phs.'\.\{-}'.phe + return text + endif + " If the user does not want to use place-holders, then remove all but the ! " first placeholder. if exists('g:Imap_UsePlaceHolders') && !g:Imap_UsePlaceHolders " a heavy-handed way to just use the first placeholder and remove the " rest. Replace the first placeholder with phe ... ! let textEnc = substitute(textEnc, '\V'.phs.'\.\{-}'.phe, pheEnc, '') " ... delete all the others ... ! let textEnc = substitute(textEnc, '\V'.phs.'\.\{-}'.phe, '', 'g') " ... and replace the first phe with phsUser.pheUser . ! let textEnc = substitute(textEnc, '\V'.phe, phsUserEnc.pheUserEnc, '') endif *************** *** 275,279 **** " NOTE: There can be more than 1 placeholders here. Therefore use a global " search and replace. ! let text = substitute(text, '\V'.phs.'\(\.\{-}\)'.phe, phsUser.'\1'.pheUser, 'g') " Now append the marker (the rare string) to the beginning of the text so " we know where the expansion started from --- 305,312 ---- " NOTE: There can be more than 1 placeholders here. Therefore use a global " search and replace. ! let textEnc = substitute(textEnc, '\V'.phs.'\(\.\{-}\)'.phe, ! \ phsUserEnc.'\1'.pheUserEnc, 'g') ! " The substitutions are done, so convert back. ! let text = iconv(textEnc, &enc, "latin1") " Now append the marker (the rare string) to the beginning of the text so " we know where the expansion started from |