Re: BufEnter Oddity After TabEnter
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 ut1|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.
Re: BufEnter Oddity After TabEnter
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. -- Best regards, Bill
Re: BufEnter Oddity After TabEnter
On Sun 5-Nov-06 3:21am -0600, Yakov Lerner wrote: On 11/5/06, Bill McCarthy [EMAIL PROTECTED] wrote: I am having a problem trying to echo a message triggered by an autocmd on BufEnter when entering a tab page. Try this: :au BufEnter foo echom Entered foo First lets try opening a window on the same tab page: :sp foo The message appears in the command line area as expected. Switching between windows, the messages is seen each time foo is entered. Wipe foo with: :bw foo Now try a tab page: :tabe foo The message appears as expected. However leaving and then entering the foo tab page does not display the message! Typing :mes shows that the message was indeed displayed. What is overwriting it? I can see this, too. The message is visible for some time if I add sleep or while getchar(1)|endwh to the rhs of 'au', but disappears right after that. Is it tab switching that causes wipeout of the message ? It shouldn't be, the tab triggers occur before the BufEnter. I modified the autocmd to do a redraw before the echo. That didn't make any difference in this case. As far as I can see, there is nothing happening after the echo - yet something is clearly clearing the line. Running with default settings, ruler is off but showcmd is on. Shutting off showcmd also made no difference. Looking to confirm the order of event triggers, I found the following at :h tabline-menu When switching to another tab page the order is: BufLeave WinLeave TabLeave TabEnter WinEnter BufEnter I decided to test this by writing the following script: Contents of tabtest.vim au BufLeave * se ch=1 au WinLeave * se ch=1 au TabLeave * se ch=1 au TabEnter * se ch=1 au WinEnter * se ch=1 au BufEnter * se ch=1 au BufEnter foo redraw|echo Entered foo tabe foo tabn se vbs=99 vfile=/pad/temp/vfile tabn qa I ran the above with this: gvim -u NONE -i NONE -N +so tabtest.vim and received this: Contents of /pad/temp/vfile line 11: tabn Executing BufLeave Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing WinLeave Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing TabLeave Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing WinEnter Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing TabEnter Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing BufEnter Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing BufEnter Auto commands for foo autocommand redraw|echo Entered foo line 0: redraw|echo Entered foo line 0: echo Entered foo Entered foo line 12: qa Although Entered foo is clearly sent to the command line, it is being wiped out by something - still unknown. Note that the order of triggering specified in the docs (and quoted above) appears to be wrong. As you can see above, TabEnter is triggered after WinEnter (not before it). -- Best regards, Bill
Re: BufEnter Oddity After TabEnter
Bill McCarthy wrote: On Sun 5-Nov-06 3:21am -0600, Yakov Lerner wrote: On 11/5/06, Bill McCarthy [EMAIL PROTECTED] wrote: I am having a problem trying to echo a message triggered by an autocmd on BufEnter when entering a tab page. Try this: :au BufEnter foo echom Entered foo First lets try opening a window on the same tab page: :sp foo The message appears in the command line area as expected. Switching between windows, the messages is seen each time foo is entered. Wipe foo with: :bw foo Now try a tab page: :tabe foo The message appears as expected. However leaving and then entering the foo tab page does not display the message! Typing :mes shows that the message was indeed displayed. What is overwriting it? I can see this, too. The message is visible for some time if I add sleep or while getchar(1)|endwh to the rhs of 'au', but disappears right after that. Is it tab switching that causes wipeout of the message ? It shouldn't be, the tab triggers occur before the BufEnter. I modified the autocmd to do a redraw before the echo. That didn't make any difference in this case. As far as I can see, there is nothing happening after the echo - yet something is clearly clearing the line. Running with default settings, ruler is off but showcmd is on. Shutting off showcmd also made no difference. Looking to confirm the order of event triggers, I found the following at :h tabline-menu When switching to another tab page the order is: BufLeave WinLeave TabLeave TabEnter WinEnter BufEnter I decided to test this by writing the following script: Contents of tabtest.vim au BufLeave * se ch=1 au WinLeave * se ch=1 au TabLeave * se ch=1 au TabEnter * se ch=1 au WinEnter * se ch=1 au BufEnter * se ch=1 au BufEnter foo redraw|echo Entered foo tabe foo tabn se vbs=99 vfile=/pad/temp/vfile tabn qa I ran the above with this: gvim -u NONE -i NONE -N +so tabtest.vim and received this: Contents of /pad/temp/vfile line 11: tabn Executing BufLeave Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing WinLeave Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing TabLeave Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing WinEnter Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing TabEnter Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing BufEnter Auto commands for * autocommand se ch=1 line 0: se ch=1 Executing BufEnter Auto commands for foo autocommand redraw|echo Entered foo line 0: redraw|echo Entered foo line 0: echo Entered foo Entered foo line 12: qa Although Entered foo is clearly sent to the command line, it is being wiped out by something - still unknown. Note that the order of triggering specified in the docs (and quoted above) appears to be wrong. As you can see above, TabEnter is triggered after WinEnter (not before it). Somehow I see neither foo 123L, 2458C nor foo [New File] in your verbosefile; I thought one of them should be issued? Does it make any difference if you set 'cmdheight' to 2 instead? Best regards, Tony.
Re: BufEnter Oddity After TabEnter
On 11/5/06, Bill McCarthy [EMAIL PROTECTED] wrote: Hello Vim List, I am having a problem trying to echo a message triggered by an autocmd on BufEnter when entering a tab page. Try this: :au BufEnter foo echom Entered foo First lets try opening a window on the same tab page: :sp foo The message appears in the command line area as expected. Switching between windows, the messages is seen each time foo is entered. Wipe foo with: :bw foo Now try a tab page: :tabe foo The message appears as expected. However leaving and then entering the foo tab page does not display the message! Typing :mes shows that the message was indeed displayed. What is overwriting it? I can see this, too. The message is visible for some time if I add sleep or while getchar(1)|endwh to the rhs of 'au', but disappears right after that. Is it tab switching that causes wipeout of the message ? Yakov