From c3e7c42207853ed0ff1a34de1c553ea7607550d7 Mon Sep 17 00:00:00 2001 From: Matt Wozniski Date: Wed, 17 Sep 2008 13:26:33 -0400 Subject: [PATCH] Clean up some ugly code in s:Highlights() --- plugin/CSApprox.vim | 51 +++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/plugin/CSApprox.vim b/plugin/CSApprox.vim index 3e4dec9..c59813e 100644 --- a/plugin/CSApprox.vim +++ b/plugin/CSApprox.vim @@ -185,6 +185,7 @@ function! s:Highlights() let i = 0 while 1 let i += 1 + " Only interested in groups that exist and aren't linked if synIDtrans(i) == 0 break @@ -195,36 +196,32 @@ function! s:Highlights() continue endif - if !has_key(rv, synIDtrans(i)) - let group = {} - let group.name = synIDattr(synIDtrans(i), "name") + let rv[i] = {} + let rv[i].name = synIDattr(i, "name") - for where in [ "term", "cterm", "gui" ] - let group[where] = {} - for attr in [ "fg", "bg", "sp", "bold", "italic", - \ "reverse", "underline", "undercurl" ] - let group[where][attr] = synIDattr(synIDtrans(i), attr, where) - endfor - - if s:NeedRedirFallback() - redir => temp - exe 'sil hi ' . group.name - redir END - let temp = matchstr(temp, where.'sp=\zs.*') - if len(temp) == 0 || temp[0] =~ '\s' - let temp = "" - else - " Make sure we can handle guisp='dark red' - let temp = substitute(temp, '[\x00].*', '', '') - let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '') - let temp = substitute(temp, '\s*$', '', '') - endif - let group[where]["sp"] = temp - endif + for where in [ "term", "cterm", "gui" ] + let rv[i][where] = {} + for attr in [ "fg", "bg", "sp", "bold", "italic", + \ "reverse", "underline", "undercurl" ] + let rv[i][where][attr] = synIDattr(i, attr, where) endfor - let rv[synIDtrans(i)] = group - endif + if s:NeedRedirFallback() + redir => temp + exe 'sil hi ' . rv[i].name + redir END + let temp = matchstr(temp, where.'sp=\zs.*') + if len(temp) == 0 || temp[0] =~ '\s' + let temp = "" + else + " Make sure we can handle guisp='dark red' + let temp = substitute(temp, '[\x00].*', '', '') + let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '') + let temp = substitute(temp, '\s*$', '', '') + endif + let rv[i][where]["sp"] = temp + endif + endfor endwhile return rv