Comment #2 on issue 177 by zyx....@gmail.com: can not wipe buffer on bufhidden
http://code.google.com/p/vim/issues/detail?id=177

I do not see you posting an exact sequence of commands you used to test this behavior. When testing your code with

    " # vim onbufhiddenwipe.vim
    " " paste your code
    " :write
    " :source %
    enew
    bnext

I see it behaving exactly as expected. But here is an educated guess on what you mean: when you edit a file and current buffer is empty, unmodified and has empty name :e uses this existing buffer to edit text in it. As it is reused it is not hidden and BufHidden does not launch. It is documented somewhere, but I do not remember where exactly.

Other issues:

1. passing <afile> as an argument and using <abuf> in a function is inconsistent. I would expect you either pass *both* <afile> and <abuf> in arguments or *none*, expanding them both in function instead. 2. never use echoerr. If you need vim to abort processing use :throw. If you need vim not to abort processing use :echom. Whenever you write :echoerr like this (*not* inside :try) you no longer know whether or not it will abort execution.

    As an example consider the following case:

    1. You have an empty buffer at the start
    2. And some plugin that switches to its buffer like this
        try
            let saved_bufnr=bufnr('%')
            execute 'buffer' plugin_bnr
            " …
        finally
            if bufexists(saved_bufnr)
                execute 'buffer' saved_bufnr
            endif
        endtry
What do you think this will result in? This will result in plugin doing nothing (it stops on `execute 'buffer' plugin_bnr` due to echoerr) and user still seeing empty buffer (because it stops on echoerr without executing next line). I.e. neither example plugin, nor your code had done its job: and all this was unexpected and due to :echoerr!
3. There is `empty()` to check for emptiness.
4. I would highly suggest never use `==` for string comparison because its meaning changes when &ignorecase option changes. It does not matter when you compare with an empty string, but it is usually a habit to use one type of string comparison everywhere. I normally use `is#` for the job, `==#` should also work.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui