Hi,

On Fri, Nov 12, 2021 at 8:14 AM Yegappan Lakshmanan <[email protected]> wrote:
>
> Hi,
>
> On Thu, Nov 11, 2021 at 8:30 PM lacygoill <[email protected]> wrote:
>>
>> Thank you very much for the quick fix. Everything works fine with maybe one 
>> exception. The default key is still absent from the output of hlget().
>
>
> The 'default' argument to the highlight command is only used to determine 
> whether the new
> attributes/link can override the already existing attributes/link and the 
> 'default' setting is not
> stored with the highlight group in the internal Vim structures. So the 
> hlget() function cannot
> return this as it is not present in the internal Vim highlight group 
> structures.
>

After sending this reply, I noticed that Vim does store the 'default'
setting for links,
but doesn't store it for highlight attributes. I have updated the PR
to return the
default setting for links.

Regards,
Yegappan

> For example, you can run the following commands:
>
> :highlight hlg1 ctermfg=2
> :highlight default hlg2 ctermfg=2
> :highlight hlg1
> hlg1           xxx ctermfg=2
> :highlight hlg2
> hlg2           xxx ctermfg=2
>
> As you can see from the above output, both hlg1 and hlg2 have similar output 
> and the
> "default" setting is missing for hlg2.
>
> Regards,
> Yegappan
>
>>
>> vim9script
>> [{name: 'MyGroup', linksto: 'ErrorMsg', default: true}]->hlset()
>> echo hlget('MyGroup')->get(0, {})->has_key('default')
>>
>> 0
>>
>> This matters if we want to create an exact duplicate of an existing 
>> highlight group, and maybe slightly alter one of its attribute. For example:
>>
>> vim9script
>> highlight default link MyGroup ErrorMsg
>> var hg_save: list<dict<any>> = hlget('MyGroup')
>> var dup: string = 'Duplicate'
>> hg_save[0]->extend({'name': dup})
>> hg_save->hlset()
>> highlight clear Duplicate
>> highlight Duplicate
>>
>> Duplicate     xxx cleared
>>
>> Notice that Duplicate is cleared. This means that when it was created by 
>> hlset(), the latter did not use default; otherwise, the link would have been 
>> automatically restored just like here:
>>
>> vim9script
>> highlight default link MyGroup ErrorMsg
>> highlight clear MyGroup
>> highlight MyGroup
>>
>> MyGroup        xxx links to ErrorMsg
>>
>> I think the issue comes from hlget() which still does not tell us whether 
>> MyGroup is linked to ErrorMsg with default or not. It would help if the 
>> output of hlget() included default: true or default: false for a linked 
>> group:
>>
>> vim9script
>> [{name: 'MyGroup', linksto: 'ErrorMsg', default: true}]->hlset()
>> echo hlget('MyGroup')
>>
>> [{'id': 54, 'linksto': 'ErrorMsg', 'default': true, 'name': 'MyGroup'}]
>>                                    ^-------------^
>>
>>

-- 
-- 
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/CAAW7x7ke%2BM_ue91y1eR3iaVttMLrf%2BwVSg0%3DR3jGVQzT%2BMMHGg%40mail.gmail.com.

Raspunde prin e-mail lui