>
> Thanks. Thus this fixes the reported problem without side effects?
I have tested it and it works fine in general. I only found a strange
behaviour in one case. I have a script which defines a cmap to <CR> and
calls a function via <C-\>e. When the function name is XX() everything
works fine, when the function name is WrapCmdLine() after pressing enter
in the expression register command line is not redraw, though it has
changes, since when I press <space><bs> it gets redrawn with the value
of the expression in the right place. You can test it with the attached
script. The function XX()=WrapCmdLine() only modifies the behaviour of
the cmdline when the cmdline starts with "! " sending the command line
to system() function rather than to the terminal directly.
I was testing with:
./vim -u NONE -i NONE --noplugin
Best regards,
Marcin Szamotulski
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
set nocompatible
let g:system_expand = 1
let g:system_echocmd = 0
cmap E expand("%:p")
fun! XX() " {{{
let cmdline = getcmdline()
if cmdline[0:1] == "! "
let cmd = cmdline[2:]
call histadd(":", cmdline)
if g:system_expand
let cmd_split = split(cmd, '\ze\\\@<!%')
let cmd = ""
for hunk in cmd_split
if hunk[0] == '%'
let m = matchstr(hunk,
'^%\%(:[p8~.htre]\|:g\=s?[^?]*?[^?]*?\)*')
let exp = expand(m)
let cmd .=exp.hunk[len(m):]
else
let cmd .=hunk
endif
endfor
endif
let cmd = escape(cmd, "\"")
let his = "|call histdel(':', -1)"
if g:system_echocmd
return "echo \"".cmd."\n\".system(\"".cmd."\")".his
else
return "echo system(\"".cmd."\")".his
endif
endif
return cmdline
endfun " }}}
cnoremap <CR> <C-\>eXX()<CR><CR>
fun! WrapCmdLine() " {{{
let cmdline = getcmdline()
if cmdline[0:1] == "! "
let cmd = cmdline[2:]
call histadd(":", cmdline)
if g:system_expand
let cmd_split = split(cmd, '\ze\\\@<!%')
let cmd = ""
for hunk in cmd_split
if hunk[0] == '%'
let m = matchstr(hunk,
'^%\%(:[p8~.htre]\|:g\=s?[^?]*?[^?]*?\)*')
let exp = expand(m)
let cmd .=exp.hunk[len(m):]
else
let cmd .=hunk
endif
endfor
endif
let cmd = escape(cmd, "\"")
let his = "|call histdel(':', -1)"
if g:system_echocmd
return "echo \"".cmd."\n\".system(\"".cmd."\")".his
else
return "echo system(\"".cmd."\")".his
endif
endif
return cmdline
endfun " }}}
" cnoremap <silent> <CR> <C-\>eWrapCmdLine()<CR><CR>