Problem with synIDattr()

28 views
Skip to first unread message

Christian Brabandt

unread,
Mar 2, 2010, 3:52:37 PM3/2/10
to vim...@vim.org
Hi,

I recently noticed, that there are some problems with synIDattr()�:

1) the standout highlighting attribute is not mentioned at the help
file or at least not at :h synIDattr()

2) you cannot query the font attribute, although you can set it.
I think this should be possible, since you can set it.

3) synIDattr() returns sometimes incorrect values. Try
gvim -u NONE -c "echo synIDattr(synIDtrans(hlID('Normal')), 'fg',
'cterm')"
This will return -1 though it should probably return an empty string,
I guess.

Attached patch fixes these problems (also available at
http://www.256bit.org/~chrisbra/patches/syIDattr.patch). You can now
query the font attribute using
gvim -u NONE -c "echo synIDattr(synIDtrans(hlID('Normal')), 'font')"

The usual disclaimer applies though: My C-Skills are rusty, so please
review carefully. I have tested this patch and it works for me on
Windows and Linux.

(BTW: could it be possible to have synIDattr() return a dictionary with
all available attributes for a highlighting group? It is very clumsy to
save the hi output without falling back to redir | hi in order to
restore it later.)


�) see this recent thread at vim_use:
http://groups.google.com/group/vim_use/browse_frm/thread/68373b7463ef2099#

regards,
Christian
--

Christian Brabandt

unread,
Mar 2, 2010, 4:39:42 PM3/2/10
to vim...@vim.org
On Di, 02 M�r 2010, Christian Brabandt wrote:

> Attached patch fixes these problems (also available at
> http://www.256bit.org/~chrisbra/patches/syIDattr.patch). You can now
> query the font attribute using
> gvim -u NONE -c "echo synIDattr(synIDtrans(hlID('Normal')), 'font')"

Grml, I guess, I just found a bug in my Checkattach plugin
(http://www.vim.org/scripts/script.php?script_id=2796). Well, here is
the patch and the plugin is fixed as well.

regards,
Christian

syIDattr.patch

Bram Moolenaar

unread,
Mar 3, 2010, 4:01:31 PM3/3/10
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

Thanks, I'll look into it soon.

--
I have to exercise early in the morning before my brain
figures out what I'm doing.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Reply all
Reply to author
Forward
0 new messages