Hi,
On Wed, Nov 10, 2021 at 2:21 PM lacygoill <[email protected]> wrote:
> To clear a highlight group with :highlight, we need to choose one of 3 Ex
> commands, depending on how it was defined.
>
> If it's defined with its own attributes, then we need :highlight clear:
>
> highlight MyGroup ctermbg=green guibg=greenhighlight clear MyGrouphighlight
> MyGroup
>
> MyGroup xxx cleared
>
> If it's linked to another highlight group, then we need to link it to NONE
> :
>
> highlight default link MyGroup ErrorMsghighlight link MyGroup NONEhighlight
> MyGroup
>
> MyGroup xxx cleared
>
> *Actually, :highlight clear might work too, but only if the group was
> defined without the default argument.*
>
> If it's defined with its own attributes *and* is linked to another
> highlight group, we need to first clear it, *then* reset its link to NONE
> (the order of the commands matters):
>
> highlight MyGroup ctermbg=green guibg=greenhighlight! default link MyGroup
> ErrorMsghighlight clear MyGrouphighlight link MyGroup NONEhighlight MyGroup
>
> MyGroup xxx cleared
>
> That's a lot of info. Using hlset() instead of :highlight does not
> simplify the operation:
>
> highlight MyGroup ctermbg=green guibg=greenhighlight! default link MyGroup
> ErrorMsgcall hlset([{'name': 'MyGroup', 'cleared': v:true, 'linksto':
> 'NONE'}])highlight MyGroup
>
> MyGroup xxx ctermbg=10 guibg=green
>
> We need 2 invocations of hlset() to be sure the group is cleared:
>
> highlight MyGroup ctermbg=green guibg=greenhighlight! default link MyGroup
> ErrorMsgcall hlset([{'name': 'MyGroup', 'cleared': v:true}])call
> hlset([{'name': 'MyGroup', 'linksto': 'NONE'}])highlight MyGroup
>
> MyGroup xxx cleared
>
> I think the first hlset() invocation fails to clear the group because it
> first removes the link then clears it (causing the link to be restored
> because of default). When both the cleared and linksto keys are present,
> wouldn't it make more sense for hlset() to process cleared *before*
> linksto?
>
>
>
I have created PR #9117 to support this.
Regards,
Yegappan
--
--
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/CAAW7x7mQ8fzux3eROj1OQCbmBpKggmxU-Nx32yd%3DgUxfDAg8xA%40mail.gmail.com.