Patch 7.4.1712
Problem:    For plugins in packages, plugin authors need to take care of all
            dependencies.
Solution:   When loading "start" packages and for :packloadall, first add all
            directories to 'runtimepath' before sourcing plugins.
Files:      src/ex_cmds2.c, src/testdir/test_packadd.vim


*** ../vim-7.4.1711/src/ex_cmds2.c      2016-04-02 22:44:12.448146599 +0200
--- src/ex_cmds2.c      2016-04-05 20:36:40.666080010 +0200
***************
*** 3313,3318 ****
--- 3313,3323 ----
      }
  }
  
+ /* used for "cookie" of add_pack_plugin() */
+ static int APP_ADD_DIR;
+ static int APP_LOAD;
+ static int APP_BOTH;
+ 
      static void
  add_pack_plugin(char_u *fname, void *cookie)
  {
***************
*** 3324,3334 ****
      int           oldlen;
      int           addlen;
      char_u  *ffname = fix_fname(fname);
-     int           load_files = cookie != NULL;
  
      if (ffname == NULL)
        return;
!     if (strstr((char *)p_rtp, (char *)ffname) == NULL)
      {
        /* directory not in 'runtimepath', add it */
        p4 = p3 = p2 = p1 = get_past_head(ffname);
--- 3329,3338 ----
      int           oldlen;
      int           addlen;
      char_u  *ffname = fix_fname(fname);
  
      if (ffname == NULL)
        return;
!     if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL)
      {
        /* directory not in 'runtimepath', add it */
        p4 = p3 = p2 = p1 = get_past_head(ffname);
***************
*** 3374,3380 ****
        vim_free(new_rtp);
      }
  
!     if (load_files)
      {
        static char *plugpat = "%s/plugin/**/*.vim";
        static char *ftpat = "%s/ftdetect/*.vim";
--- 3378,3384 ----
        vim_free(new_rtp);
      }
  
!     if (cookie != &APP_ADD_DIR)
      {
        static char *plugpat = "%s/plugin/**/*.vim";
        static char *ftpat = "%s/ftdetect/*.vim";
***************
*** 3423,3430 ****
      if (!did_source_packages || (eap != NULL && eap->forceit))
      {
        did_source_packages = TRUE;
        do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
!                                                       add_pack_plugin, p_pp);
      }
  }
  
--- 3427,3440 ----
      if (!did_source_packages || (eap != NULL && eap->forceit))
      {
        did_source_packages = TRUE;
+ 
+       /* First do a round to add all directories to 'runtimepath', then load
+        * the plugins. This allows for plugins to use an autoload directory
+        * of another plugin. */
+       do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
+                                              add_pack_plugin, &APP_ADD_DIR);
        do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
!                                                 add_pack_plugin, &APP_LOAD);
      }
  }
  
***************
*** 3444,3450 ****
        return;
      vim_snprintf(pat, len, plugpat, eap->arg);
      do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR,
!                                add_pack_plugin, eap->forceit ? NULL : p_pp);
      vim_free(pat);
  }
  
--- 3454,3460 ----
        return;
      vim_snprintf(pat, len, plugpat, eap->arg);
      do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR,
!                   add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
      vim_free(pat);
  }
  
*** ../vim-7.4.1711/src/testdir/test_packadd.vim        2016-04-02 
22:44:12.448146599 +0200
--- src/testdir/test_packadd.vim        2016-04-05 20:54:29.151250331 +0200
***************
*** 87,100 ****
  endfunc
  
  func Test_packloadall()
!   let plugindir = &packpath . '/pack/mine/start/foo/plugin'
!   call mkdir(plugindir, 'p')
!   call writefile(['let g:plugin_foo_number = 1234'], plugindir . '/bar.vim')
    packloadall
    call assert_equal(1234, g:plugin_foo_number)
  
    " only works once
!   call writefile(['let g:plugin_bar_number = 4321'], plugindir . '/bar2.vim')
    packloadall
    call assert_false(exists('g:plugin_bar_number'))
  
--- 87,125 ----
  endfunc
  
  func Test_packloadall()
!   " plugin foo with an autoload directory
!   let fooplugindir = &packpath . '/pack/mine/start/foo/plugin'
!   call mkdir(fooplugindir, 'p')
!   call writefile(['let g:plugin_foo_number = 1234',
!       \ 'let g:plugin_foo_auto = bbb#value',
!       \ 'let g:plugin_extra_auto = extra#value'], fooplugindir . '/bar.vim')
!   let fooautodir = &packpath . '/pack/mine/start/foo/autoload'
!   call mkdir(fooautodir, 'p')
!   call writefile(['let bar#value = 77'], fooautodir . '/bar.vim')
! 
!   " plugin aaa with an autoload directory
!   let aaaplugindir = &packpath . '/pack/mine/start/aaa/plugin'
!   call mkdir(aaaplugindir, 'p')
!   call writefile(['let g:plugin_aaa_number = 333',
!       \ 'let g:plugin_aaa_auto = bar#value'], aaaplugindir . '/bbb.vim')
!   let aaaautodir = &packpath . '/pack/mine/start/aaa/autoload'
!   call mkdir(aaaautodir, 'p')
!   call writefile(['let bbb#value = 55'], aaaautodir . '/bbb.vim')
! 
!   " plugin extra with only an autoload directory
!   let extraautodir = &packpath . '/pack/mine/start/extra/autoload'
!   call mkdir(extraautodir, 'p')
!   call writefile(['let extra#value = 99'], extraautodir . '/extra.vim')
! 
    packloadall
    call assert_equal(1234, g:plugin_foo_number)
+   call assert_equal(55, g:plugin_foo_auto)
+   call assert_equal(99, g:plugin_extra_auto)
+   call assert_equal(333, g:plugin_aaa_number)
+   call assert_equal(77, g:plugin_aaa_auto)
  
    " only works once
!   call writefile(['let g:plugin_bar_number = 4321'], fooplugindir . 
'/bar2.vim')
    packloadall
    call assert_false(exists('g:plugin_bar_number'))
  
*** ../vim-7.4.1711/src/version.c       2016-04-05 21:10:19.429575920 +0200
--- src/version.c       2016-04-05 21:12:25.896289343 +0200
***************
*** 750,751 ****
--- 750,753 ----
  {   /* Add new patch number below this line */
+ /**/
+     1712,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
228. You spend Saturday night making the counter on your home page
     pass that 2000 mark.

 /// 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