Hello,

I have a problem with an old hack that works fine in latin1, but starts
to cause problems in UTF-8.

The hack helps to replace activation key-sequences from i-mappings with
their mapped value, which are actually calls to script-local functions.

What is quite odd is that I have a workaround on Linux (by calling
iconv()) which has no, useful, effect on Windows (win32 build).

The problem has existed for a long time. The iconv() workaround works
correctly with vim 7.0.012 on linux, but not with vim 7.0.000 (default
win32 build) on windows.

Is there a solution to my problem (may be a patch for vim) ? Or have I
to change the scope of my i-mapped local-functions to global ?

Thank in advance for any hint.

Here follows a simplified viml code that illustrates what I'm trying to
achieve.

----------- >% ------------
" script1
function! s:foo()
  " complex computations according to context, ...
  return "foo"
endfunction

inoremap !foo! <c-r>=<sid>foo()<cr>

" ======================================
" script2 in real situation
function! s:bar()
  let foo = '!foo!'
  let m = maparg(foo,'i')
  if strlen(m) != 0
    exe 'let m="' . 
       \ substitute(m, '<\(.\{-1,}\)>', '"."\\<\1>"."', 'g') . '"'
    if has('iconv')
      " uncomment the following line to activate the workaround on linux
      " let m = iconv(m, 'latin1', &encoding)
    endif
  endif
  return 'bar'.m.'bar'
endfunction

inoremap bfb <c-r>=<sid>bar()<cr>
----------- >% ------------


-- 
Luc Hermitte
http://hermitte.free.fr/vim/

Reply via email to