Patch 7.4.2117
Problem:    Deleting an augroup that still has autocmds does not give a
            warning.  The next defined augroup takes its place.
Solution:   Give a warning and prevent the index being used for another group
            name.
Files:      src/fileio.c, src/testdir/test_autocmd.vim


*** ../vim-7.4.2116/src/fileio.c        2016-07-26 20:43:37.016311805 +0200
--- src/fileio.c        2016-07-29 20:39:53.537537790 +0200
***************
*** 7758,7763 ****
--- 7758,7764 ----
   */
  static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
  #define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
+ static char_u *deleted_augroup = NULL;
  
  /*
   * The ID of the current group.  Group 0 is the default one.
***************
*** 7812,7818 ****
        if (ap->group != AUGROUP_DEFAULT)
        {
            if (AUGROUP_NAME(ap->group) == NULL)
!               msg_puts_attr((char_u *)_("--Deleted--"), hl_attr(HLF_E));
            else
                msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T));
            msg_puts((char_u *)"  ");
--- 7813,7819 ----
        if (ap->group != AUGROUP_DEFAULT)
        {
            if (AUGROUP_NAME(ap->group) == NULL)
!               msg_puts_attr(deleted_augroup, hl_attr(HLF_E));
            else
                msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T));
            msg_puts((char_u *)"  ");
***************
*** 8009,8016 ****
        EMSG2(_("E367: No such group: \"%s\""), name);
      else
      {
        vim_free(AUGROUP_NAME(i));
!       AUGROUP_NAME(i) = NULL;
      }
  }
  
--- 8010,8040 ----
        EMSG2(_("E367: No such group: \"%s\""), name);
      else
      {
+       event_T event;
+       AutoPat *ap;
+       int     in_use = FALSE;
+ 
+       for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
+                                           event = (event_T)((int)event + 1))
+       {
+           for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
+               if (ap->group == i)
+               {
+                   give_warning((char_u *)_("W19: Deleting augroup that is 
still in use"), TRUE);
+                   in_use = TRUE;
+                   event = NUM_EVENTS;
+                   break;
+               }
+       }
        vim_free(AUGROUP_NAME(i));
!       if (in_use)
!       {
!           if (deleted_augroup == NULL)
!               deleted_augroup = (char_u *)_("--Deleted--");
!           AUGROUP_NAME(i) = deleted_augroup;
!       }
!       else
!           AUGROUP_NAME(i) = NULL;
      }
  }
  
***************
*** 8024,8030 ****
      int           i;
  
      for (i = 0; i < augroups.ga_len; ++i)
!       if (AUGROUP_NAME(i) != NULL && STRCMP(AUGROUP_NAME(i), name) == 0)
            return i;
      return AUGROUP_ERROR;
  }
--- 8048,8055 ----
      int           i;
  
      for (i = 0; i < augroups.ga_len; ++i)
!       if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != deleted_augroup
!               && STRCMP(AUGROUP_NAME(i), name) == 0)
            return i;
      return AUGROUP_ERROR;
  }
***************
*** 8081,8090 ****
      void
  free_all_autocmds(void)
  {
      for (current_augroup = -1; current_augroup < augroups.ga_len;
                                                            ++current_augroup)
        do_autocmd((char_u *)"", TRUE);
!     ga_clear_strings(&augroups);
  }
  #endif
  
--- 8106,8125 ----
      void
  free_all_autocmds(void)
  {
+     int               i;
+     char_u    *s;
+ 
      for (current_augroup = -1; current_augroup < augroups.ga_len;
                                                            ++current_augroup)
        do_autocmd((char_u *)"", TRUE);
! 
!     for (i = 0; i < augroups.ga_len; ++i)
!     {
!       s = ((char_u **)(augroups.ga_data))[i];
!       if (s != deleted_augroup)
!           vim_free(s);
!     }
!     ga_clear(&augroups);
  }
  #endif
  
***************
*** 9830,9836 ****
        return (char_u *)"END";
      if (idx >= augroups.ga_len)               /* end of list */
        return NULL;
!     if (AUGROUP_NAME(idx) == NULL)    /* skip deleted entries */
        return (char_u *)"";
      return AUGROUP_NAME(idx);         /* return a name */
  }
--- 9865,9872 ----
        return (char_u *)"END";
      if (idx >= augroups.ga_len)               /* end of list */
        return NULL;
!     if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == deleted_augroup)
!       /* skip deleted entries */
        return (char_u *)"";
      return AUGROUP_NAME(idx);         /* return a name */
  }
***************
*** 9894,9900 ****
  {
      if (idx < augroups.ga_len)                /* First list group names, if 
wanted */
      {
!       if (!include_groups || AUGROUP_NAME(idx) == NULL)
            return (char_u *)"";        /* skip deleted entries */
        return AUGROUP_NAME(idx);       /* return a name */
      }
--- 9930,9937 ----
  {
      if (idx < augroups.ga_len)                /* First list group names, if 
wanted */
      {
!       if (!include_groups || AUGROUP_NAME(idx) == NULL
!                                      || AUGROUP_NAME(idx) == deleted_augroup)
            return (char_u *)"";        /* skip deleted entries */
        return AUGROUP_NAME(idx);       /* return a name */
      }
*** ../vim-7.4.2116/src/testdir/test_autocmd.vim        2016-07-26 
20:43:37.016311805 +0200
--- src/testdir/test_autocmd.vim        2016-07-29 20:42:50.587870506 +0200
***************
*** 151,153 ****
--- 151,170 ----
    au! vimBarTest|echo 'hello'
    call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
  endfunc
+ 
+ func Test_augroup_warning()
+   augroup TheWarning
+     au VimEnter * echo 'entering'
+   augroup END
+   call assert_true(match(execute('au VimEnter'), "TheWarning.*VimEnter") >= 0)
+   redir => res
+   augroup! TheWarning
+   redir END
+   call assert_true(match(res, "W19:") >= 0)
+   call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
+ 
+   " check "Another" does not take the pace of the deleted entry
+   augroup Another
+   augroup END
+   call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
+ endfunc
*** ../vim-7.4.2116/src/version.c       2016-07-29 18:33:34.864824393 +0200
--- src/version.c       2016-07-29 20:49:04.420350607 +0200
***************
*** 760,761 ****
--- 760,763 ----
  {   /* Add new patch number below this line */
+ /**/
+     2117,
  /**/

-- 
Why don't cannibals eat clowns?
Because they taste funny.

 /// Bram Moolenaar -- b...@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    ///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui