To: vim_dev@googlegroups.com Subject: Patch 8.0.1400 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1400 Problem: Color scheme check script shows up as color scheme. Solution: Move it to the "tools" subdirectory. (closes #2457) Files: Filelist, runtime/colors/check_colors.vim, runtime/colors/tools/check_colors.vim, runtime/colors/README.txt *** ../vim-8.0.1399/Filelist 2017-11-28 14:18:51.089377798 +0100 --- Filelist 2017-12-17 16:05:33.513359307 +0100 *************** *** 666,671 **** --- 666,672 ---- runtime/autoload/xml/*.vim \ runtime/colors/*.vim \ runtime/colors/README.txt \ + runtime/colors/tools/*.vim \ runtime/compiler/*.vim \ runtime/compiler/README.txt \ runtime/indent/*.vim \ *** ../vim-8.0.1399/runtime/colors/check_colors.vim 2017-12-16 18:53:01.675551340 +0100 --- runtime/colors/check_colors.vim 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,136 **** - " This script tests a color scheme for some errors. Load the scheme and source - " this script. e.g. :e colors/desert.vim | :so test_colors.vim - " Will output possible errors. - - let s:save_cpo= &cpo - set cpo&vim - - func! Test_check_colors() - call cursor(1,1) - let err={} - - " 1) Check g:colors_name is existing - if !search('\<\%(g:\)\?colors_name\>', 'cnW') - let err['colors_name'] = 'g:colors_name not set' - else - let err['colors_name'] = 'OK' - endif - - " 2) Check for some well-defined highlighting groups - " Some items, check several groups, e.g. Diff, Spell - let hi_groups = ['ColorColumn', 'Diff', 'ErrorMsg', 'Folded', - \ 'FoldColumn', 'IncSearch', 'LineNr', 'ModeMsg', 'MoreMsg', 'NonText', - \ 'Normal', 'Pmenu', 'Todo', 'Search', 'Spell', 'StatusLine', 'TabLine', - \ 'Title', 'Visual', 'WarningMsg', 'WildMenu'] - let groups={} - for group in hi_groups - if search('\c@suppress\s\+'.group, 'cnW') - " skip check, if the script contains a line like - " @suppress Visual: - let groups[group] = 'Ignoring '.group - continue - endif - if !search('hi\%[ghlight] \+'.group, 'cnW') - let groups[group] = 'No highlight definition for '.group - continue - endif - if !search('hi\%[ghlight] \+'.group. '.*fg=', 'cnW') - let groups[group] = 'Missing foreground color for '.group - continue - endif - if search('hi\%[ghlight] \+'.group. '.*guibg=', 'cnW') && - \ !search('hi\%[ghlight] \+'.group. '.*ctermbg=', 'cnW') - let groups[group] = 'Missing bg terminal color for '.group - continue - endif - call search('hi\%[ghlight] \+'.group, 'cW') - " only check in the current line - if !search('guifg', 'cnW', line('.')) || !search('ctermfg', 'cnW', line('.')) - " do not check for background colors, they could be intentionally left out - let groups[group] = 'Missing fg definition for '.group - endif - call cursor(1,1) - endfor - let err['highlight'] = groups - - " 3) Check, that it does not set background highlighting - " Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes? - let bg_set='\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)' - let bg_let='let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1' - let bg_pat='\%('.bg_set. '\|'.bg_let.'\)' - let line=search(bg_pat, 'cnW') - if search(bg_pat, 'cnW') - exe line - if search('hi \U\w\+\s\+\S', 'cbnW') - let err['background'] = 'Should not set background option after :hi statement' - endif - else - let err['background'] = 'OK' - endif - call cursor(1,1) - - " 4) Check, that t_Co is checked - let pat = '[&]t_Co\s*[<>=]=\?\s*\d\+' - if !search(pat, 'ncW') - let err['t_Co'] = 'Does not check terminal for capable colors' - endif - - " 5) Initializes correctly, e.g. should have a section like - " hi clear - " if exists("syntax_on") - " syntax reset - " endif - let pat='hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif' - if !search(pat, 'cnW') - let err['init'] = 'No initialization' - endif - - " 6) Does not use :syn on - if search('syn\%[tax]\s\+on', 'cnW') - let err['background'] = 'Should not issue :syn on' - endif - - " 7) Does not define filetype specfic groups like vimCommand, htmlTag, - let hi_groups = ['vim', 'html', 'python', 'sh', 'ruby'] - for group in hi_groups - let pat='\Chi\%[ghlight]\s*\zs'.group.'\w\+\>' - if search(pat, 'cnW') - let line = search(pat, 'cW') - let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' ' - endif - call cursor(1,1) - endfor - let g:err = err - - " print Result - call Result(err) - endfu - - fu! Result(err) - let do_roups = 0 - echohl Title|echomsg "---------------"|echohl Normal - for key in sort(keys(a:err)) - if key is# 'highlight' - let do_groups = 1 - continue - else - if a:err[key] !~ 'OK' - echohl Title - endif - echomsg printf("%15s: %s", key, a:err[key]) - echohl Normal - endif - endfor - echohl Title|echomsg "---------------"|echohl Normal - if do_groups - echohl Title | echomsg "Groups" | echohl Normal - for v1 in sort(keys(a:err['highlight'])) - echomsg printf("%25s: %s", v1, a:err['highlight'][v1]) - endfor - endif - endfu - - call Test_check_colors() - - let &cpo = s:save_cpo - unlet s:save_cpo --- 0 ---- *** ../vim-8.0.1399/runtime/colors/tools/check_colors.vim 1970-01-01 01:00:00.000000000 +0100 --- runtime/colors/tools/check_colors.vim 2017-12-16 18:42:07.880088994 +0100 *************** *** 0 **** --- 1,136 ---- + " This script tests a color scheme for some errors. Load the scheme and source + " this script. e.g. :e colors/desert.vim | :so test_colors.vim + " Will output possible errors. + + let s:save_cpo= &cpo + set cpo&vim + + func! Test_check_colors() + call cursor(1,1) + let err={} + + " 1) Check g:colors_name is existing + if !search('\<\%(g:\)\?colors_name\>', 'cnW') + let err['colors_name'] = 'g:colors_name not set' + else + let err['colors_name'] = 'OK' + endif + + " 2) Check for some well-defined highlighting groups + " Some items, check several groups, e.g. Diff, Spell + let hi_groups = ['ColorColumn', 'Diff', 'ErrorMsg', 'Folded', + \ 'FoldColumn', 'IncSearch', 'LineNr', 'ModeMsg', 'MoreMsg', 'NonText', + \ 'Normal', 'Pmenu', 'Todo', 'Search', 'Spell', 'StatusLine', 'TabLine', + \ 'Title', 'Visual', 'WarningMsg', 'WildMenu'] + let groups={} + for group in hi_groups + if search('\c@suppress\s\+'.group, 'cnW') + " skip check, if the script contains a line like + " @suppress Visual: + let groups[group] = 'Ignoring '.group + continue + endif + if !search('hi\%[ghlight] \+'.group, 'cnW') + let groups[group] = 'No highlight definition for '.group + continue + endif + if !search('hi\%[ghlight] \+'.group. '.*fg=', 'cnW') + let groups[group] = 'Missing foreground color for '.group + continue + endif + if search('hi\%[ghlight] \+'.group. '.*guibg=', 'cnW') && + \ !search('hi\%[ghlight] \+'.group. '.*ctermbg=', 'cnW') + let groups[group] = 'Missing bg terminal color for '.group + continue + endif + call search('hi\%[ghlight] \+'.group, 'cW') + " only check in the current line + if !search('guifg', 'cnW', line('.')) || !search('ctermfg', 'cnW', line('.')) + " do not check for background colors, they could be intentionally left out + let groups[group] = 'Missing fg definition for '.group + endif + call cursor(1,1) + endfor + let err['highlight'] = groups + + " 3) Check, that it does not set background highlighting + " Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes? + let bg_set='\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)' + let bg_let='let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1' + let bg_pat='\%('.bg_set. '\|'.bg_let.'\)' + let line=search(bg_pat, 'cnW') + if search(bg_pat, 'cnW') + exe line + if search('hi \U\w\+\s\+\S', 'cbnW') + let err['background'] = 'Should not set background option after :hi statement' + endif + else + let err['background'] = 'OK' + endif + call cursor(1,1) + + " 4) Check, that t_Co is checked + let pat = '[&]t_Co\s*[<>=]=\?\s*\d\+' + if !search(pat, 'ncW') + let err['t_Co'] = 'Does not check terminal for capable colors' + endif + + " 5) Initializes correctly, e.g. should have a section like + " hi clear + " if exists("syntax_on") + " syntax reset + " endif + let pat='hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif' + if !search(pat, 'cnW') + let err['init'] = 'No initialization' + endif + + " 6) Does not use :syn on + if search('syn\%[tax]\s\+on', 'cnW') + let err['background'] = 'Should not issue :syn on' + endif + + " 7) Does not define filetype specfic groups like vimCommand, htmlTag, + let hi_groups = ['vim', 'html', 'python', 'sh', 'ruby'] + for group in hi_groups + let pat='\Chi\%[ghlight]\s*\zs'.group.'\w\+\>' + if search(pat, 'cnW') + let line = search(pat, 'cW') + let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' ' + endif + call cursor(1,1) + endfor + let g:err = err + + " print Result + call Result(err) + endfu + + fu! Result(err) + let do_roups = 0 + echohl Title|echomsg "---------------"|echohl Normal + for key in sort(keys(a:err)) + if key is# 'highlight' + let do_groups = 1 + continue + else + if a:err[key] !~ 'OK' + echohl Title + endif + echomsg printf("%15s: %s", key, a:err[key]) + echohl Normal + endif + endfor + echohl Title|echomsg "---------------"|echohl Normal + if do_groups + echohl Title | echomsg "Groups" | echohl Normal + for v1 in sort(keys(a:err['highlight'])) + echomsg printf("%25s: %s", v1, a:err['highlight'][v1]) + endfor + endif + endfu + + call Test_check_colors() + + let &cpo = s:save_cpo + unlet s:save_cpo *** ../vim-8.0.1399/runtime/colors/README.txt 2017-12-16 18:53:01.675551340 +0100 --- runtime/colors/README.txt 2017-12-17 16:03:08.190439541 +0100 *************** *** 64,70 **** If you think you have a color scheme that is good enough to be used by others, please check the following items: ! - Source the check_colors.vim script to check for common mistakes. - Does it work in a color terminal as well as in the GUI? - Is "g:colors_name" set to a meaningful value? In case of doubt you can do it this way: --- 64,70 ---- If you think you have a color scheme that is good enough to be used by others, please check the following items: ! - Source the tools/check_colors.vim script to check for common mistakes. - Does it work in a color terminal as well as in the GUI? - Is "g:colors_name" set to a meaningful value? In case of doubt you can do it this way: *** ../vim-8.0.1399/src/version.c 2017-12-17 14:54:57.199422897 +0100 --- src/version.c 2017-12-17 16:05:15.161513167 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1400, /**/ -- Amnesia is one of my favorite words, but I forgot what it means. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///