Sunday, December 6, 2020

Re: Autocommand bug when reloading file

On Sun, Dec 06, 2020 at 08:10:29AM -0600, Felipe Contreras wrote:
>It does not matter what I have. I already explained a situation that
>is inconsistent.
>
> #!/bin/sh
>
> cat > /tmp/vim_test_rc <<EOF
> set nocompatible
> syntax enable
> filetype plugin indent on
> au! FileType sh setl et ts=2
> au! BufRead,BufNewFile /tmp/test.sh setl noet ts=8
> EOF
>
> gvim -u /tmp/vim_test_rc -c "set et?" /tmp/test.sh
> sleep 10
> echo >> /tmp/test.sh
>
>What does "set et?" return initially?
>
>And what does it return 10 seconds later after the file is reloaded?

You can see what is happening more clearly if you set the autocmds to echomsg something unique. When opening or :edit-ing a file, the FileType autocmd runs first, followed by the BufRead,BufNewFile autocmd. When gvim's W11 prompt triggers a "Load File", the BufRead autocmd runs before the FileType autocmd. In all cases, after/ftplugin/sh.vim is loaded immediately before the FileType trigger executes. This is all neither here nor there if you use ftplugin instead of autocmds.

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201206180405.GA5992%40rainslide.net.

No comments: