On 17:51 Mon 22 Jul     , Bram Moolenaar wrote:
> 
> Pokey Rule wrote:
> 
> > I run vim with no file on the command-line, so that it shows the
> > scratch buffer. When I then run
> > 
> > :e foo
> > 
> > to edit file 'foo', there is a BufUnload event triggered for file
> > 'foo'. Here is a test vim command that I use to demonstrate the issue:
> > 
> > autocmd BufUnload * echom "Unloaded " . expand("<afile>")
> > 
> > I posted this issue to stackoverflow, where user Ingo Karkat responded:
> > 
> > I can reproduce this with the latest Vim 7.4a.39. I guess this has to
> > do with the fact that Vim reuses the initial scratch buffer number (1)
> > for the first :edited file. Please report this problem to the vim_dev
> > mailing list.
> 
> Thanks, I'll add a note to the todo list.
> 
> -- 
> hundred-and-one symptoms of being an internet addict:
> 8. You spend half of the plane trip with your laptop on your lap...and your
>    child in the overhead compartment.
> 
>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org        ///
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
> 

Hello,

Here is a patch.  I tested that it works with :cclose, and :lclose
commands, i.e. does not block BufUnload on them.

Are there any other commands that should be checked?

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


diff -r 3f65dc9c8840 src/buffer.c
--- a/src/buffer.c	Sun Jul 21 18:59:24 2013 +0200
+++ b/src/buffer.c	Mon Jul 22 17:48:13 2013 +0100
@@ -566,7 +566,8 @@
     int		is_curbuf = (buf == curbuf);
 
     buf->b_closing = TRUE;
-    apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
+    if (!(buf->b_fname == NULL && buf->b_ffname != NULL))
+	apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
     if (!buf_valid(buf))	    /* autocommands may delete the buffer */
 	return;
     if ((flags & BFA_DEL) && buf->b_p_bl)

Raspunde prin e-mail lui