Hi,

On Mon, May 23, 2022 at 5:58 PM lacygoill <[email protected]> wrote:

> If a group is not specified, then the default group will be used.
> [...]
> If we make 'replace' the default, then a call to autocmd_add() in a .vimrc
> file will remove commands added by a plugin (in the default group) for
> that event.
> A user may not expect this.
>
> IMO, an autocmd should always be added in a named augroup; not in the
> default one. Unless we're quickly testing some feature.
>
> I was not clear enough in the previous post, sorry. My idea was for unique
> /replace to be considered only when the autocmd was placed in a named
> augroup. Because AFAIK the default augroup can't be cleared specifically
> (right?). So, it wouldn't make sense for autocmd_add() to provide a
> feature which was not also provided by :autocmd.
>
And if replace is ignored for the default augroup, then there would be no
> issue (right?).
>

You can use ":autocmd!" to remove the commands associated with an event
in the default group and add a new command. e.g.

autocmd CursorHold * echo "cmd1"
autocmd CursorHold * echo "cmd2"
autocmd! CursorHold * echo "cmd3"

Currently autocmd_add() doesn't support this feature. I have created
PR 10473
to add this.

Regards,
Yegappan


> The only counter-argument I can find is that it would make replace more
> complicated to understand. But IMO, doing what the user expects is more
> important. And to quote :help local-options
> <https://vimhelp.org/options.txt.html#local-options>:
>
> Unfortunately, doing what the user expects is a bit complicated...
>
> Anyway, the mere introduction of replace would already be a big
> improvement. Making it default for *named* augroups would be even better,
> but not that important.
>
> Thank you very much for working on these functions, they're very useful.
>
>
>

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7nm0Gt6hGoXtMHSUKy0cd%3DZ0Kn5w3axXuemY%3DS4-8LhcA%40mail.gmail.com.

Raspunde prin e-mail lui