On 02/11/2015 04:50 AM, Justin M. Keyes wrote:
> On Tue, Jan 27, 2015 at 5:26 AM, Bram Moolenaar wrote:
>>
>> Xavier de Gaye wrote:
>>
>>> On 01/25/2015 03:59 PM, Bram Moolenaar wrote:
>>>   > Xavier de Gaye wrote:
>>>   >> In the following test case, 'foobar' and  'dummy_file' are two
>>>   >> non-existent files:
>>>   >>
>>>   >> gvim -o foobar dummy_file
>>>   >>     :set buftype=nofile
>>>   >>     :call append(1, "second line")    -> foobar contains now two lines
>>>   >>     <CTRL-W> W
>>>   >>     :edit foobar                      -> a) foobar still contains two 
lines
>>>   >>     :edit foobar                      -> b) Ooops... foobar contains 
no lines now !
>>>   >>
>>>   >> The problem is that do_ecmd() does not handle this case in a 
consistent way, whether:
>>>   >> 1) foobar is not curbuf and therefore 'other_file' is true (in case 
(a) above)
>>>   >> 2) or foobar is curbuf and therefore 'other_file' is false (in case 
(b) above) in which case buf_clear_file(curbuf) is invoked by do_ecmd()
>>>   >
>>>   > If you do this with a file then the same thing happens, except that you
>>>   > will get an error at the second ":edit foobar", since the buffer was
>>>   > changed and you are trying to drop the changes.
>>>   >
>>>   > It may seem a bit inconsistant, but changing this will most likely cause
>>>   > some plugins to fail in a weird way.  Better just keep it as it is.
>>>
>>>
>>> When the user ':edit' or ':'tabedit' a buffer that is managed by an
>>> application using netbeans to control the buffer (with the netbeans
>>> 'editFile' command for example), the buffer may be cleared
>>> without the knowledge of the application. This is annoying and it is
>>> the reason why I have submitted this problem.
>>>
>>> It may make sense that ':edit' should attempt to reload the buffer
>>> when it is a file, but it is strange that this command may (or may
>>> not) clear the buffer when there is no file to reload from, and
>>> very strange that this behavior depends on the position of the cursor.
>>
>> Well, I suppose what we could do, without causing too much trouble, is
>> making ":e foobar" a no-op for a file where 'buftype' is "nofile" and
>> "foobar" is already the current buffer.  It would be unexpected that a
>> plugin relies on this edit command to make the buffer empty.
>
> Will ":e" on an existing "nofile" buffer still raise the BufNewFile
> event (or any other events)? This is a useful convention for plugins
> to know when to "reload" a nofile buffer.


The problem is that ':edit' behavior on a 'nofile' buffer is (before 7.4.592)
inconsistent: it clears the buffer when the cursor is in that buffer but
leaves it unchanged otherwise. So relying on a BufNewFile event when this
command is issued is not safe.

Xavier

--
--
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/d/optout.

Raspunde prin e-mail lui