Patch 8.0.1777
Problem:    Cannot cleanup before loading another colorscheme.
Solution:   Add the ColorSchemePre autocommand event.
Files:      src/fileio.c, src/syntax.c, src/vim.h, src/testdir/test_gui.vim,
            runtime/colors/README.txt



*** ../vim-8.0.1776/src/fileio.c        2018-04-29 13:34:42.942051531 +0200
--- src/fileio.c        2018-04-30 15:12:09.336923068 +0200
***************
*** 7734,7739 ****
--- 7734,7740 ----
      {"CmdwinLeave",   EVENT_CMDWINLEAVE},
      {"CmdUndefined",  EVENT_CMDUNDEFINED},
      {"ColorScheme",   EVENT_COLORSCHEME},
+     {"ColorSchemePre",        EVENT_COLORSCHEMEPRE},
      {"CompleteDone",  EVENT_COMPLETEDONE},
      {"CursorHold",    EVENT_CURSORHOLD},
      {"CursorHoldI",   EVENT_CURSORHOLDI},
***************
*** 9479,9485 ****
       */
      if (fname_io == NULL)
      {
!       if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET)
            autocmd_fname = NULL;
        else if (fname != NULL && !ends_excmd(*fname))
            autocmd_fname = fname;
--- 9480,9487 ----
       */
      if (fname_io == NULL)
      {
!       if (event == EVENT_COLORSCHEME || event == EVENT_COLORSCHEMEPRE
!                                                  || event == EVENT_OPTIONSET)
            autocmd_fname = NULL;
        else if (fname != NULL && !ends_excmd(*fname))
            autocmd_fname = fname;
***************
*** 9549,9554 ****
--- 9551,9557 ----
                || event == EVENT_SPELLFILEMISSING
                || event == EVENT_QUICKFIXCMDPRE
                || event == EVENT_COLORSCHEME
+               || event == EVENT_COLORSCHEMEPRE
                || event == EVENT_OPTIONSET
                || event == EVENT_QUICKFIXCMDPOST
                || event == EVENT_DIRCHANGED)
*** ../vim-8.0.1776/src/syntax.c        2018-03-20 13:00:07.190308819 +0100
--- src/syntax.c        2018-04-30 15:12:37.208715902 +0200
***************
*** 7224,7229 ****
--- 7224,7231 ----
      buf = alloc((unsigned)(STRLEN(name) + 12));
      if (buf != NULL)
      {
+       apply_autocmds(EVENT_COLORSCHEMEPRE, name,
+                                              curbuf->b_fname, FALSE, curbuf);
        sprintf((char *)buf, "colors/%s.vim", name);
        retval = source_runtime(buf, DIP_START + DIP_OPT);
        vim_free(buf);
*** ../vim-8.0.1776/src/vim.h   2018-04-29 12:22:49.167522589 +0200
--- src/vim.h   2018-04-30 15:12:48.056635501 +0200
***************
*** 1277,1282 ****
--- 1277,1283 ----
      EVENT_CMDWINENTER,                /* after entering the cmdline window */
      EVENT_CMDWINLEAVE,                /* before leaving the cmdline window */
      EVENT_COLORSCHEME,                /* after loading a colorscheme */
+     EVENT_COLORSCHEMEPRE,     /* before loading a colorscheme */
      EVENT_COMPLETEDONE,               /* after finishing insert complete */
      EVENT_CURSORHOLD,         /* cursor in same position for a while */
      EVENT_CURSORHOLDI,                /* idem, in Insert mode */
*** ../vim-8.0.1776/src/testdir/test_gui.vim    2018-02-27 17:17:32.439413984 
+0100
--- src/testdir/test_gui.vim    2018-04-30 15:16:37.322961475 +0200
***************
*** 33,45 ****
--- 33,57 ----
  
  func Test_colorscheme()
    let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default'
+   let g:color_count = 0
+   augroup TestColors
+     au!
+     au ColorScheme * let g:color_count += 1| let g:after_colors = 
g:color_count
+     au ColorSchemePre * let g:color_count += 1 |let g:before_colors = 
g:color_count
+   augroup END
  
    colorscheme torte
    redraw!
    sleep 200m
    call assert_equal('dark', &background)
+   call assert_equal(1, g:before_colors)
+   call assert_equal(2, g:after_colors)
  
    exec 'colorscheme' colorscheme_saved
+   augroup TestColors
+     au!
+   augroup END
+   unlet g:color_count g:after_colors g:before_colors
    redraw!
  endfunc
  
*** ../vim-8.0.1776/runtime/colors/README.txt   2017-12-17 16:10:51.182858654 
+0100
--- runtime/colors/README.txt   2018-04-30 15:07:52.886877560 +0200
***************
*** 42,48 ****
  Replace "blue_sky" with the name of the colorscheme.
  
  In case you want to tweak a colorscheme after it was loaded, check out the
! ColorScheme autocmd event.
  
  To customize a colorscheme use another name, e.g.  "~/.vim/colors/mine.vim",
  and use `:runtime` to load the original colorscheme:
--- 42,57 ----
  Replace "blue_sky" with the name of the colorscheme.
  
  In case you want to tweak a colorscheme after it was loaded, check out the
! ColorScheme autocommand event.
! 
! To clean up just before loading another colorscheme, use the ColorSchemePre
! autocommand event.  For example:
!       let g:term_ansi_colors = ...
!       augroup MyColorscheme
!         au!
!         au ColorSchemePre * unlet g:term_ansi_colors
!         au ColorSchemePre * au! MyColorscheme
!       augroup END
  
  To customize a colorscheme use another name, e.g.  "~/.vim/colors/mine.vim",
  and use `:runtime` to load the original colorscheme:
*** ../vim-8.0.1776/src/version.c       2018-04-30 14:28:20.448618066 +0200
--- src/version.c       2018-04-30 15:13:00.628542475 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1777,
  /**/

-- 
You were lucky to have a LAKE! There were a hundred and sixty of
us living in a small shoebox in the middle of the road.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui