Skip to content
Browse files

bugfix to org#GetGroupHighlight, now won't break if no group exists o…

…r group is cleared, deleted cruft from OrgSetColors()
  • Loading branch information...
1 parent 03a7258 commit 21c4ad43606bdd058cf293d9534d9b500a140538 @hsitz committed Dec 18, 2011
Showing with 16 additions and 28 deletions.
  1. +13 −4 autoload/org.vim
  2. +3 −24 ftplugin/org.vim
View
17 autoload/org.vim
@@ -71,7 +71,11 @@ function! org#GetGroupHighlight(group)
" Redirect the output of the "hi" command into a variable
" and find the highlighting
redir => GroupDetails
- exe "silent hi " . a:group
+ try
+ exe "silent hi " . a:group
+ catch
+ " skip error message if no such group exists
+ endtry
redir END
" Resolve linked groups to find the root highlighting scheme
@@ -83,9 +87,14 @@ function! org#GetGroupHighlight(group)
redir END
endwhile
- " Extract the highlighting details (the bit after "xxx")
- let MatchGroups = matchlist(GroupDetails, '\<xxx\>\s\+\(.*\)')
- let ExistingHighlight = MatchGroups[1]
+ if GroupDetails ># ''
+ " Extract the highlighting details (the bit after "xxx")
+ let MatchGroups = matchlist(GroupDetails, '\<xxx\>\s\+\(.*\)')
+ let ExistingHighlight = MatchGroups[1] !~? 'cleared' ? MatchGroups[1] : ''
+ else
+ " Group does not exist
+ let ExistingHighlight = ''
+ endif
return ExistingHighlight
View
27 ftplugin/org.vim
@@ -7538,23 +7538,7 @@ function! OrgSetColors()
\ ['OL4','Comment'], ['OL5','Special'] ]
execute 'hi clear ' . pair[0]
execute 'hi clear ' . pair[0] .'Folded'
- execute 'hi ' . pair[0] . ' ' . org#GetGroupHighlight( pair[1] )
- execute 'hi ' . pair[0] . 'Folded ' . org#GetGroupHighlight( pair[1] )
- execute 'hi ' . pair[0] . ' gui=NONE'
- execute 'hi ' . pair[0] . 'Folded gui=bold'
- endfor
- " set up highlights to use for headlines
- " involves create new set of highlights to
- " correspond to OL1-OL5, but this time with bold flag
- " folded headlines use different highlights:
- " folded OL1 uses Folded
- " folded OL2 uses WarningMsg
- " folded OL3 uses WildMenu
- " folded OL4 uses DiffAdd
- " folded OL5 uses DiffChange
- "for pair in [ ['Folded','Statement'], ['WarningMsg','Identifier'], ['WildMenu','Constant'],
- " \ ['DiffAdd','Comment'], ['DiffChange','Special'] ]
- " execute 'hi clear ' . pair[0]
+ execute 'hi ' . pair[0] . ' ' . org#GetGroupHighlight( pair[1] )
execute 'hi ' . pair[0] . 'Folded ' . org#GetGroupHighlight( pair[1] )
execute 'hi ' . pair[0] . ' gui=NONE'
execute 'hi ' . pair[0] . 'Folded gui=bold'
@@ -7564,10 +7548,10 @@ function! OrgSetColors()
hi! FoldColumn guifg=bg guibg=bg
else
try
- hi! FoldColumn ctermfg=bg ctermbg=bg
+ hi! FoldColumn ctermfg=bg ctermbg=bg
catch
hi! FoldColumn ctermfg=0 ctermbg=0
- endtry
+ endtry
endif
"show text on SignColumn
@@ -7614,14 +7598,9 @@ function! OrgSetColors()
if has("conceal")
hi! default linkends guifg=blue ctermfg=blue
- endif
endif
hi! Org_Full_Link guifg=cyan gui=underline ctermfg=lightblue cterm=underline
hi! Org_Half_Link guifg=cyan gui=underline ctermfg=lightblue cterm=underline
-
- "hi! GENERICTODO guifg=pink ctermfg=lightred
- hi! DONETODO guifg=green ctermfg=green
- hi! NOTDONETODO guifg=red ctermfg=lightred
highlight OrgColumnHeadings guibg=#444444 guifg=#aaaaaa gui=underline
hi! DONETODO guifg=green ctermfg=green

0 comments on commit 21c4ad4

Please sign in to comment.
Something went wrong with that request. Please try again.