BufNew not triggered for matching file specified on the command line

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

BufNew not triggered for matching file specified on the command line

Dun Peal
I have the following in my ~/.vim/filetype.vim:

augroup markdown
    au! BufNew *.md echom "I was called"
augroup END

This gets executed if I launch vim, then execute:

    :e foo.md

However, if I launch vim like so:

    $ vim foo.md

This does not get called - the message is missing from :messages

This behaviour appears to contradict the docs:


Is this a bug?

Here's my :version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  1 2016 13:05:21)
MacOS X (unix) version
Included patches: 1-1655
Compiled by Homebrew
Huge version without GUI.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BufNew not triggered for matching file specified on the command line

Dun Peal
Any ideas?  Is this a bug?  Should I post this somewhere else?

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BufNew not triggered for matching file specified on the command line

Gary Johnson-4
On 2016-05-15, Dun Peal wrote:
> Any ideas?  Is this a bug?  Should I post this somewhere else?

This is the right place.  I can reproduce the behavior.  It looks
like a bug to me.  I was hoping for a response from someone more
knowledgable about buffer behavior.

Regards,
Gary

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BufNew not triggered for matching file specified on the command line

Justin M. Keyes
On Mon, May 16, 2016 at 2:01 AM, Gary Johnson <[hidden email]> wrote:
> On 2016-05-15, Dun Peal wrote:
>> Any ideas?  Is this a bug?  Should I post this somewhere else?
>
> This is the right place.  I can reproduce the behavior.  It looks
> like a bug to me.  I was hoping for a response from someone more
> knowledgable about buffer behavior.

I noticed this behavior as well, described here:

https://github.com/justinmk/vim-dirvish/issues/23#issuecomment-182754960

I assumed it was intentional, or if not intentional then will be
documented as intentional if anyone mentions it.

Justin M. Keyes

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BufNew not triggered for matching file specified on the command line

Dun Peal
Reading the link Justin posted, seems like this is a limitation resulting from the design of Vim.

Given this limitation, is there another way to run post-creation setup on *all* matching buffers, including those created for files specified on the CLI?

I need to set the filetype and run a bunch of setup commands on *.md buffers. BufNew was the only proper way I found to do this, and apparently I can't count on it to work in all cases.

Is there an alternative?

My current "workaround" has been to use BufRead instead. It is not optimal: it triggers every time the buffer is re-read, which is far more often than I need it to run (only once when the buffer is created).

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BufNew not triggered for matching file specified on the command line

Paul-4
In reply to this post by Dun Peal
On Sunday, 15 May, 2016 at 15:51:40 BST, Dun Peal wrote:
>Any ideas?  Is this a bug?  Should I post this somewhere else?

I guess it differentiates from BufNewFile, just below it in :help…

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.