-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
autocmd: introduce "++once" flag #4100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a new feature to :autocmd which sets the handler to be executed at most one times. Before: augroup FooGroup autocmd! autocmd FileType foo call Foo() | autocmd! FooGroup * <buffer> augroup END After: autocmd FileType foo once call Foo()
Codecov Report
@@ Coverage Diff @@
## master #4100 +/- ##
==========================================
- Coverage 79.24% 79.24% -0.01%
==========================================
Files 105 105
Lines 141163 141177 +14
==========================================
+ Hits 111860 111871 +11
- Misses 29303 29306 +3
Continue to review full report at Codecov.
|
That's weird syntax. I'd think |
If any of So let's not get mired in hypotheticals, the goal is only to be slightly less inconsistent with Vim's predominant idioms. |
If any of `MyGroup BufRead *` were valid commands then they also would
be "hidden" as `:autocmd` struggles to decide which is an `augroup`
and which is a valid command. It's all weird because `:autocmd` is
weird. Hyphenated flags are slightly less weird and as mentioned
consistent with `:command` itself.
Not many Ex commands use a dash for an option. That's mainly because a
file name can start with a dash.
More commands use the ++option form. Some the <option> form.
It's hard to decide what to use for new options to existing commands.
The ++option form appears to be the most common choice. AFAIK it's
easier to type ++option than <option> on most keyboards.
…--
hundred-and-one symptoms of being an internet addict:
51. You put a pillow case over your laptop so your lover doesn't see it while
you are pretending to catch your breath.
/// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///
|
Based on feedback from upstream: vim/vim#4100
Renamed to |
Based on feedback from upstream: vim/vim#4100
Based on feedback from upstream: vim/vim#4100
Based on feedback from upstream: vim/vim#4100
|
Angle-bracket variants are unpleasant to type as already mentioned. |
hmm.. that looks like an obscure way to pre-increment the option to “twice” |
Angle-bracket variants are unpleasant to type as already mentioned. |
Problem: If autocmd pattern only contained `++once` handlers, and all of them completed, then there would be an empty group displayed by `:autocmd Foo`. Solution: Delete the pattern if all of its commands were deleted.
Thanks, Bram! |
Problem: Making an autocommand trigger once is not so easy. Solution: Add the ++once argument. Also add ++nested as an alias for "nested". (Justin M. Keyes, closes vim/vim#4100) vim/vim@eb93f3f
The main cat mode function is started in an autocomand but normal autocomands don't nest. They are made nesting in order to detect and highlight the filetype on buffer switches in highlight() (see :h autocmd-nested). The "++nested" syntax in the docs was introduced with neovim v0.4 (and vim/vim#4100). For compatibility with neovim < 0.4 we use the old "nested" which still seems to work.
Adds a new feature to :autocmd which sets the handler to be executed once, then removed.
Before:
After:
once
flag to-once
and also adds support for-nested
. This is to avoid yet another "flags" pattern not seen anywhere else in Vim, and instead be consistent with e.g.:command
flags pattern.++once
and++nested