fun! WipeOutAll()
for i in range(1, bufnr('$'))
exe "silent! bw" i
endfor
endfun
fun! OnRemoving()
let name = expand('<afile>')
exe "b" name
call append("$", "Refuse to die")
endfun
sp buffer1
au BufWipeout <buffer> call OnRemoving()
sp buffer2
au BufWipeout <buffer> call OnRemoving()
call WipeOutAll()
This code shows 2 unexpected behaviors:
1) After ":source" this test script, ":ls" reports:
2 %h + "buffer1" line 1
but the doc says 'hidden' buffers are not displayed.
2) Both "Refuse to die" lines goes into one buffer, but I think they
should be dispatched to each buffer (I mean one line per buffer) before
they are being wiped out.
Vim-7.2-166
Thanks.
--
Dasn
You are shooting yourself in the foot. In the BufWipeout command you
should not start editing another buffer, weird things may happen, such
as wiping out the wrong buffer.
I'll see if I can catch the situation and give an error message.
--
ROBIN: (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN: Oh ... wacho!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
IMHO it ought to be mentioned in the help (where I don't see it, in the
help for |BufWipeout| in autocmd.txt dated 2009 Mar 01; nor do I see a
similar warning under |BufUnload| or |BufDelete| whose text is otherwise
quite similar).
Best regards,
Tony.
--
Parkinson's Fourth Law:
The number of people in any working group tends to increase
regardless of the amount of work to be done.
> On 09/05/09 21:20, Bram Moolenaar wrote:
> > Dasn wrote:
> >
> >> Accessing buffer in 'BufDelete' or 'BufWipeout' autocmd makes hidden
> >> buffer displayed. Here's the test code:
> [...]
> > You are shooting yourself in the foot. In the BufWipeout command you
> > should not start editing another buffer, weird things may happen, such
> > as wiping out the wrong buffer.
> >
> > I'll see if I can catch the situation and give an error message.
> >
>
> IMHO it ought to be mentioned in the help (where I don't see it, in the
> help for |BufWipeout| in autocmd.txt dated 2009 Mar 01; nor do I see a
> similar warning under |BufUnload| or |BufDelete| whose text is otherwise
> quite similar).
I had added a remark at BufWipeout, I'll do the same for BufUnload and
BufDelete.
--
Lawmakers made it obligatory for everybody to take at least one bath
each week -- on Saturday night.
[real standing law in Vermont, United States of America]