Skip to content

autocmd: rename: "++nested", "++once" #9728

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

Merged
merged 2 commits into from
Mar 15, 2019
Merged

Conversation

justinmk
Copy link
Member

  • Rename -once => ++once based on feedback from autocmd: introduce "++once" flag vim/vim#4100
  • Fix a small bug: if autocmd pattern only contained ++once handlers, and all of them completed, then there would be an empty group displayed by :autocmd Foo.

@justinmk justinmk changed the title autocmd: rename "-once" => "++once" autocmd: rename: "++nested", "++once" Mar 13, 2019
@justinmk justinmk force-pushed the autocmd-once branch 2 times, most recently from 31ed668 to 29ddd4a Compare March 13, 2019 23:12
Based on feedback from upstream:
vim/vim#4100
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.
@ilAYAli
Copy link
Contributor

ilAYAli commented Mar 15, 2019

++once looks like an obscure way to pre-increment the parameter to twice
<once> looks much better, even though it might be slightly harder to type (ref: the vim discussion)

@justinmk
Copy link
Member Author

justinmk commented Mar 15, 2019

@ilAYAli angle brackets are onerous. Imagine if shell commands required every option to be wrapped in brackets.

++ looks like preincrement syntax, - looks like "negative", <> looks like HTML, ... syntax is always context-dependent, there's no avoiding that.

++ is for better or worse what Vim uses for :edit and :terminal. I would prefer hyphen, I don't understand why ++ is better than hyphen.

@justinmk
Copy link
Member Author

Merging this because it fixes 2 bugs.

@justinmk justinmk merged commit 1baf4ed into neovim:master Mar 15, 2019
@justinmk justinmk deleted the autocmd-once branch March 15, 2019 11:38
@ilAYAli
Copy link
Contributor

ilAYAli commented Mar 15, 2019

@justinmk ++once looks ambiguous.
Regardless, both a hyphen prefix or angle brackets looks much better, and makes it clear that once is a parameter.

@@ -363,8 +363,8 @@ static void set_bg_deferred(void **argv)
if (starting) {
// Wait until after startup, so OptionSet is triggered.
do_cmdline_cmd((bgvalue[0] == 'l')
? "autocmd VimEnter * once nested set background=light"
: "autocmd VimEnter * once nested set background=dark");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to rename this to -once last time...

@justinmk
Copy link
Member Author

justinmk commented Mar 15, 2019

Any confusion about ++once is cleared up by the K command which takes the user to :help autocmd-once. There are zero Ex commands where ++ means "pre-increment".

Happy to rename it back to -once if someone convinces Bram to do so.

@bfredl
Copy link
Member

bfredl commented Mar 15, 2019

As it happens, both a lone - and double -- can be ranges (thus -once and --once is still theoretically valid commands), but on the other hand ++ is not a range, which would be a reason to prefer ++once .

@justinmk justinmk added has:vim-patch issue is fixed in vim and patch needs to be ported enhancement labels Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has:vim-patch issue is fixed in vim and patch needs to be ported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants