On 11/8/06, Bill McCarthy <[EMAIL PROTECTED]> wrote:
On Mon 6-Nov-06 11:02pm -0600, you wrote:
> There is not-a-solution-but-weird-workaround at
> http://www.vim.org/tips/tip.php?tip_id=1379
> Tip #1379: make echo seen when it would otherwise disappear and go unseen
Nice idea. I've expanded it a bit by changing the
CursorHold to get rid of itself and restore the previous
value of 'updatetime'. The following was added to your tip:
" The following is a self destructive version of the
" CursorHold autocmd. It also restores 'updatetime'.
let s:Pecho=''
fu! s:Pecho(msg)
if &ut!=11|let s:hold_ut=&ut|let &ut=11|en
let s:Pecho=a:msg
aug Pecho
au CursorHold * if s:Pecho!=''|echo s:Pecho
\|let s:Pecho=''|let &ut=s:hold_ut|en
\|aug Pecho|exe 'au!'|aug END|aug! Pecho
aug END
endf
" Test of above
au! BufEnter foo call s:Pecho("Entered foo")
" Now even changing to "foo" in a different tab page
" will print the message.
I filed another change at http://www.vim.org/tips/tip.php?tip_id=1379
to this piece that makes it safe when two or more scripts use
this same technique simultaneously (otheriwse, &ut restoration
can go wrong, order of autocommands triggering is unpredictable).
Bill, do you think the "if s:Pecho!=''|' check in autocommand is necessary ?
Yakov
" further improvement in restoration of the &updatetime. To make this
" usable in the plugins, we want it to be safe for the case when
" two plugins use same this same technique. Two independent
" restorations of &ut can run in unpredictable order. In order to
" make it safe, we add additional check in &ut restoration.
let s:Pecho=''
fu! s:Pecho(msg)
let s:hold_ut=&ut | if &ut>1|let &ut=1|en
let s:Pecho=a:msg
aug Pecho
au CursorHold * if s:Pecho!=''|echo s:Pecho
\|let s:Pecho=''|if s:hold_ut > &ut |let &ut=s:hold_ut|en|en
\|aug Pecho|exe 'au!'|aug END|aug! Pecho
aug END
endf
In this form, I think it's safe for use in plugins.