Use try-finally for reverting the setup

This commit is contained in:
Junegunn Choi
2013-09-19 17:27:26 +09:00
parent 1752bf567b
commit fce0a103ff

View File

@@ -92,6 +92,7 @@ let s:prev_echon_len = 0
function! s:echon_(msg) function! s:echon_(msg)
" http://vim.wikia.com/wiki/How_to_print_full_screen_width_messages " http://vim.wikia.com/wiki/How_to_print_full_screen_width_messages
let xy = [&ruler, &showcmd] let xy = [&ruler, &showcmd]
try
set noruler noshowcmd set noruler noshowcmd
let winlen = winwidth(winnr()) - 2 let winlen = winwidth(winnr()) - 2
let msg = len(a:msg) > winlen ? (a:msg[0 : winlen - 3] . '..') : a:msg let msg = len(a:msg) > winlen ? (a:msg[0 : winlen - 3] . '..') : a:msg
@@ -101,7 +102,9 @@ function! s:echon_(msg)
endif endif
echon "\r". msg echon "\r". msg
let s:prev_echon_len = len let s:prev_echon_len = len
finally
let [&ruler, &showcmd] = xy let [&ruler, &showcmd] = xy
endtry
endfunction endfunction
function! s:echon(l, n, d, o) function! s:echon(l, n, d, o)