Patch 7.4.2015
Problem:    When a file gets a name when writing it 'acd' is not effective.
            (Dan Church)
Solution:   Invoke DO_AUTOCHDIR after writing the file. (Allen Haim, closes
            #777, closes #803)  Add test_autochdir() to enable 'acd' before
            "starting" is reset.
Files:      src/ex_cmds.c, src/buffer.c, src/eval.c, src/globals.h,
            src/Makefile, src/testdir/test_autochdir.vim,
            src/testdir/Make_all.mak


*** ../vim-7.4.2014/src/ex_cmds.c       2016-07-03 17:47:21.862812533 +0200
--- src/ex_cmds.c       2016-07-09 23:39:18.288083297 +0200
***************
*** 3059,3064 ****
--- 3059,3065 ----
      char_u    *browse_file = NULL;
  #endif
      buf_T     *alt_buf = NULL;
+     int               name_was_missing;
  
      if (not_writing())                /* check 'write' option */
        return FAIL;
***************
*** 3226,3231 ****
--- 3227,3234 ----
  #endif
        }
  
+       name_was_missing = curbuf->b_ffname == NULL;
+ 
        retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
                                 eap, eap->append, eap->forceit, TRUE, FALSE);
  
***************
*** 3239,3245 ****
                redraw_tabline = TRUE;
  #endif
            }
!           /* Change directories when the 'acd' option is set. */
            DO_AUTOCHDIR
        }
      }
--- 3242,3253 ----
                redraw_tabline = TRUE;
  #endif
            }
!       }
! 
!       /* Change directories when the 'acd' option is set and the file name
!        * got changed or set. */
!       if (eap->cmdidx == CMD_saveas || name_was_missing)
!       {
            DO_AUTOCHDIR
        }
      }
*** ../vim-7.4.2014/src/buffer.c        2016-07-09 15:20:48.688771385 +0200
--- src/buffer.c        2016-07-09 23:29:11.120936763 +0200
***************
*** 1635,1641 ****
      void
  do_autochdir(void)
  {
!     if (starting == 0
            && curbuf->b_ffname != NULL
            && vim_chdirfile(curbuf->b_ffname) == OK)
        shorten_fnames(TRUE);
--- 1635,1641 ----
      void
  do_autochdir(void)
  {
!     if ((starting == 0 || test_autochdir)
            && curbuf->b_ffname != NULL
            && vim_chdirfile(curbuf->b_ffname) == OK)
        shorten_fnames(TRUE);
*** ../vim-7.4.2014/src/eval.c  2016-07-09 18:49:47.198420006 +0200
--- src/eval.c  2016-07-09 23:32:29.326048130 +0200
***************
*** 812,817 ****
--- 812,818 ----
  static void f_tagfiles(typval_T *argvars, typval_T *rettv);
  static void f_tempname(typval_T *argvars, typval_T *rettv);
  static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
+ static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
  static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
  static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
  #ifdef FEAT_JOB_CHANNEL
***************
*** 8832,8837 ****
--- 8833,8839 ----
  #endif
      {"tempname",      0, 0, f_tempname},
      {"test_alloc_fail",       3, 3, f_test_alloc_fail},
+     {"test_autochdir",        0, 0, f_test_autochdir},
      {"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
      {"test_garbagecollect_now",       0, 0, f_test_garbagecollect_now},
  #ifdef FEAT_JOB_CHANNEL
***************
*** 13155,13161 ****
      {
        if (wp->w_localdir != NULL)
            rettv->vval.v_string = vim_strsave(wp->w_localdir);
!       else if(globaldir != NULL)
            rettv->vval.v_string = vim_strsave(globaldir);
        else
        {
--- 13157,13163 ----
      {
        if (wp->w_localdir != NULL)
            rettv->vval.v_string = vim_strsave(wp->w_localdir);
!       else if (globaldir != NULL)
            rettv->vval.v_string = vim_strsave(globaldir);
        else
        {
***************
*** 21077,21082 ****
--- 21079,21095 ----
  }
  
  /*
+  * "test_autochdir()"
+  */
+     static void
+ f_test_autochdir(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
+ {
+ #if defined(FEAT_AUTOCHDIR)
+     test_autochdir = TRUE;
+ #endif
+ }
+ 
+ /*
   * "test_disable_char_avail({expr})" function
   */
      static void
*** ../vim-7.4.2014/src/globals.h       2016-07-09 17:05:49.207222368 +0200
--- src/globals.h       2016-07-09 23:31:01.403329700 +0200
***************
*** 635,640 ****
--- 635,643 ----
  EXTERN int    really_exiting INIT(= FALSE);
                                /* TRUE when we are sure to exit, e.g., after
                                 * a deadly signal */
+ #if defined(FEAT_AUTOCHDIR)
+ EXTERN int    test_autochdir INIT(= FALSE);
+ #endif
  #if defined(EXITFREE)
  EXTERN int    entered_free_all_mem INIT(= FALSE);
                                /* TRUE when in or after free_all_mem() */
*** ../vim-7.4.2014/src/Makefile        2016-07-09 17:05:49.207222368 +0200
--- src/Makefile        2016-07-09 22:47:03.882113238 +0200
***************
*** 2016,2021 ****
--- 2016,2022 ----
  test_arglist \
        test_assert \
        test_assign \
+       test_autochdir \
        test_autocmd \
        test_backspace_opt \
        test_cdo \
*** ../vim-7.4.2014/src/testdir/test_autochdir.vim      2016-07-09 
23:38:54.692427608 +0200
--- src/testdir/test_autochdir.vim      2016-07-09 23:34:33.432238648 +0200
***************
*** 0 ****
--- 1,17 ----
+ " Test 'autochdir' behavior
+ 
+ if !exists("+autochdir")
+   finish
+ endif
+ 
+ func Test_set_filename()
+   call test_autochdir()
+   set acd
+   new
+   w samples/Xtest
+   call assert_equal("Xtest", expand('%'))
+   call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
+   bwipe!
+   set noacd
+   call delete('samples/Xtest')
+ endfunc
*** ../vim-7.4.2014/src/testdir/Make_all.mak    2016-07-02 18:25:15.724879148 
+0200
--- src/testdir/Make_all.mak    2016-07-09 22:47:27.369763653 +0200
***************
*** 164,169 ****
--- 164,170 ----
  # Keep test_alot*.res as the last one, sort the others.
  NEW_TESTS = test_arglist.res \
            test_assert.res \
+           test_autochdir \
            test_backspace_opt.res \
            test_cdo.res \
            test_channel.res \
*** ../vim-7.4.2014/src/version.c       2016-07-09 21:57:16.630640033 +0200
--- src/version.c       2016-07-09 22:46:23.510714111 +0200
***************
*** 760,761 ****
--- 760,763 ----
  {   /* Add new patch number below this line */
+ /**/
+     2015,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
255. You work for a newspaper and your editor asks you to write an
     article about Internet addiction...in the "first person."

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