d985c78
To: vim-dev@vim.org
d985c78
Subject: Patch 7.0.087
d985c78
Fcc: outbox
d985c78
From: Bram Moolenaar <Bram@moolenaar.net>
d985c78
Mime-Version: 1.0
d985c78
Content-Type: text/plain; charset=ISO-8859-1
d985c78
Content-Transfer-Encoding: 8bit
d985c78
------------
d985c78
d985c78
Patch 7.0.087
d985c78
Problem:    After ":file fname" and ":saveas fname" the 'autochdir' option
d985c78
	    does not take effect. (Yakov Lerner)
d985c78
	    Commands for handling 'autochdir' are repeated many times.
d985c78
Solution:   Add the DO_AUTOCHDIR macro and do_autochdir().  Use it for
d985c78
	    ":file fname" and ":saveas fname".
d985c78
Files:	    src/proto/buffer.pro, src/buffer.c, src/ex_cmds.c, src/macros.h,
d985c78
	    src/option.c, src/window.c
d985c78
d985c78
d985c78
*** ../vim-7.0.086/src/proto/buffer.pro	Sun Apr 30 20:25:32 2006
d985c78
--- src/proto/buffer.pro	Tue Sep  5 16:25:40 2006
d985c78
***************
d985c78
*** 10,15 ****
d985c78
--- 10,16 ----
d985c78
  extern int do_buffer __ARGS((int action, int start, int dir, int count, int forceit));
d985c78
  extern void set_curbuf __ARGS((buf_T *buf, int action));
d985c78
  extern void enter_buffer __ARGS((buf_T *buf));
d985c78
+ extern void do_autochdir __ARGS((void));
d985c78
  extern buf_T *buflist_new __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum, int flags));
d985c78
  extern void free_buf_options __ARGS((buf_T *buf, int free_p_ff));
d985c78
  extern int buflist_getfile __ARGS((int n, linenr_T lnum, int options, int forceit));
d985c78
*** ../vim-7.0.086/src/buffer.c	Tue Aug 29 16:52:01 2006
d985c78
--- src/buffer.c	Tue Sep  5 15:18:19 2006
d985c78
***************
d985c78
*** 434,445 ****
d985c78
      if (usingNetbeans)
d985c78
  	netbeans_file_closed(buf);
d985c78
  #endif
d985c78
! #ifdef FEAT_AUTOCHDIR
d985c78
!     /* Change directories when the acd option is set on. */
d985c78
!     if (p_acd && curbuf->b_ffname != NULL
d985c78
! 				     && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
! 	shorten_fnames(TRUE);
d985c78
! #endif
d985c78
  
d985c78
      /*
d985c78
       * Remove the buffer from the list.
d985c78
--- 434,441 ----
d985c78
      if (usingNetbeans)
d985c78
  	netbeans_file_closed(buf);
d985c78
  #endif
d985c78
!     /* Change directories when the 'acd' option is set. */
d985c78
!     DO_AUTOCHDIR
d985c78
  
d985c78
      /*
d985c78
       * Remove the buffer from the list.
d985c78
***************
d985c78
*** 1422,1433 ****
d985c78
  	netbeans_file_activated(curbuf);
d985c78
  #endif
d985c78
  
d985c78
! #ifdef FEAT_AUTOCHDIR
d985c78
!     /* Change directories when the acd option is set on. */
d985c78
!     if (p_acd && curbuf->b_ffname != NULL
d985c78
! 				     && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
! 	shorten_fnames(TRUE);
d985c78
! #endif
d985c78
  
d985c78
  #ifdef FEAT_KEYMAP
d985c78
      if (curbuf->b_kmap_state & KEYMAP_INIT)
d985c78
--- 1418,1425 ----
d985c78
  	netbeans_file_activated(curbuf);
d985c78
  #endif
d985c78
  
d985c78
!     /* Change directories when the 'acd' option is set. */
d985c78
!     DO_AUTOCHDIR
d985c78
  
d985c78
  #ifdef FEAT_KEYMAP
d985c78
      if (curbuf->b_kmap_state & KEYMAP_INIT)
d985c78
***************
d985c78
*** 1435,1440 ****
d985c78
--- 1427,1444 ----
d985c78
  #endif
d985c78
      redraw_later(NOT_VALID);
d985c78
  }
d985c78
+ 
d985c78
+ #if defined(FEAT_AUTOCHDIR) || defined(PROTO)
d985c78
+ /*
d985c78
+  * Change to the directory of the current buffer.
d985c78
+  */
d985c78
+     void
d985c78
+ do_autochdir()
d985c78
+ {
d985c78
+     if (curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
+ 	shorten_fnames(TRUE);
d985c78
+ }
d985c78
+ #endif
d985c78
  
d985c78
  /*
d985c78
   * functions for dealing with the buffer list
d985c78
*** ../vim-7.0.086/src/ex_cmds.c	Tue Aug 29 17:28:56 2006
d985c78
--- src/ex_cmds.c	Tue Sep  5 15:24:58 2006
d985c78
***************
d985c78
*** 2458,2463 ****
d985c78
--- 2458,2465 ----
d985c78
  #ifdef FEAT_AUTOCMD
d985c78
  	apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
d985c78
  #endif
d985c78
+ 	/* Change directories when the 'acd' option is set. */
d985c78
+ 	DO_AUTOCHDIR
d985c78
      }
d985c78
      /* print full file name if :cd used */
d985c78
      fileinfo(FALSE, FALSE, eap->forceit);
d985c78
***************
d985c78
*** 2675,2682 ****
d985c78
  				 eap, eap->append, eap->forceit, TRUE, FALSE);
d985c78
  
d985c78
  	/* After ":saveas fname" reset 'readonly'. */
d985c78
! 	if (eap->cmdidx == CMD_saveas && retval == OK)
d985c78
! 	    curbuf->b_p_ro = FALSE;
d985c78
      }
d985c78
  
d985c78
  theend:
d985c78
--- 2677,2689 ----
d985c78
  				 eap, eap->append, eap->forceit, TRUE, FALSE);
d985c78
  
d985c78
  	/* After ":saveas fname" reset 'readonly'. */
d985c78
! 	if (eap->cmdidx == CMD_saveas)
d985c78
! 	{
d985c78
! 	    if (retval == OK)
d985c78
! 		curbuf->b_p_ro = FALSE;
d985c78
! 	    /* Change directories when the 'acd' option is set. */
d985c78
! 	    DO_AUTOCHDIR
d985c78
! 	}
d985c78
      }
d985c78
  
d985c78
  theend:
d985c78
***************
d985c78
*** 3547,3557 ****
d985c78
  	foldUpdateAll(curwin);
d985c78
  #endif
d985c78
  
d985c78
! #ifdef FEAT_AUTOCHDIR
d985c78
! 	if (p_acd && curbuf->b_ffname != NULL
d985c78
! 				     && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
! 	    shorten_fnames(TRUE);
d985c78
! #endif
d985c78
  	/*
d985c78
  	 * Careful: open_buffer() and apply_autocmds() may change the current
d985c78
  	 * buffer and window.
d985c78
--- 3554,3562 ----
d985c78
  	foldUpdateAll(curwin);
d985c78
  #endif
d985c78
  
d985c78
! 	/* Change directories when the 'acd' option is set. */
d985c78
! 	DO_AUTOCHDIR
d985c78
! 
d985c78
  	/*
d985c78
  	 * Careful: open_buffer() and apply_autocmds() may change the current
d985c78
  	 * buffer and window.
d985c78
***************
d985c78
*** 3718,3729 ****
d985c78
      if (p_im)
d985c78
  	need_start_insertmode = TRUE;
d985c78
  
d985c78
! #ifdef FEAT_AUTOCHDIR
d985c78
!     /* Change directories when the acd option is set on. */
d985c78
!     if (p_acd && curbuf->b_ffname != NULL
d985c78
! 				     && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
! 	shorten_fnames(TRUE);
d985c78
! #endif
d985c78
  
d985c78
  #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
d985c78
      if (gui.in_use && curbuf->b_ffname != NULL)
d985c78
--- 3723,3730 ----
d985c78
      if (p_im)
d985c78
  	need_start_insertmode = TRUE;
d985c78
  
d985c78
!     /* Change directories when the 'acd' option is set. */
d985c78
!     DO_AUTOCHDIR
d985c78
  
d985c78
  #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
d985c78
      if (gui.in_use && curbuf->b_ffname != NULL)
d985c78
*** ../vim-7.0.086/src/macros.h	Wed Mar  1 23:00:25 2006
d985c78
--- src/macros.h	Tue Sep  5 15:15:30 2006
d985c78
***************
d985c78
*** 276,278 ****
d985c78
--- 276,284 ----
d985c78
  # define MB_CHARLEN(p)		STRLEN(p)
d985c78
  # define PTR2CHAR(p)		((int)*(p))
d985c78
  #endif
d985c78
+ 
d985c78
+ #ifdef FEAT_AUTOCHDIR
d985c78
+ # define DO_AUTOCHDIR if (p_acd) do_autochdir();
d985c78
+ #else
d985c78
+ # define DO_AUTOCHDIR
d985c78
+ #endif
d985c78
*** ../vim-7.0.086/src/option.c	Tue Aug 29 17:28:56 2006
d985c78
--- src/option.c	Tue Sep  5 15:20:04 2006
d985c78
***************
d985c78
*** 7326,7334 ****
d985c78
  #ifdef FEAT_AUTOCHDIR
d985c78
      else if ((int *)varp == &p_acd)
d985c78
      {
d985c78
! 	if (p_acd && curbuf->b_ffname != NULL
d985c78
! 				     && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
! 	    shorten_fnames(TRUE);
d985c78
      }
d985c78
  #endif
d985c78
  
d985c78
--- 7326,7333 ----
d985c78
  #ifdef FEAT_AUTOCHDIR
d985c78
      else if ((int *)varp == &p_acd)
d985c78
      {
d985c78
! 	/* Change directories when the 'acd' option is set now. */
d985c78
! 	DO_AUTOCHDIR
d985c78
      }
d985c78
  #endif
d985c78
  
d985c78
*** ../vim-7.0.086/src/window.c	Tue Aug 29 17:28:56 2006
d985c78
--- src/window.c	Tue Sep  5 15:20:35 2006
d985c78
***************
d985c78
*** 3954,3966 ****
d985c78
      setmouse();			/* in case jumped to/from help buffer */
d985c78
  #endif
d985c78
  
d985c78
! #ifdef FEAT_AUTOCHDIR
d985c78
!     /* Change directories when the 'acd' option is set on and after
d985c78
!      * switching windows. */
d985c78
!     if (p_acd && curbuf->b_ffname != NULL
d985c78
! 				     && vim_chdirfile(curbuf->b_ffname) == OK)
d985c78
! 	shorten_fnames(TRUE);
d985c78
! #endif
d985c78
  }
d985c78
  
d985c78
  #endif /* FEAT_WINDOWS */
d985c78
--- 3954,3961 ----
d985c78
      setmouse();			/* in case jumped to/from help buffer */
d985c78
  #endif
d985c78
  
d985c78
!     /* Change directories when the 'acd' option is set. */
d985c78
!     DO_AUTOCHDIR
d985c78
  }
d985c78
  
d985c78
  #endif /* FEAT_WINDOWS */
d985c78
*** ../vim-7.0.086/src/version.c	Tue Sep  5 15:36:30 2006
d985c78
--- src/version.c	Tue Sep  5 15:52:45 2006
d985c78
***************
d985c78
*** 668,669 ****
d985c78
--- 668,671 ----
d985c78
  {   /* Add new patch number below this line */
d985c78
+ /**/
d985c78
+     87,
d985c78
  /**/
d985c78
d985c78
-- 
d985c78
Overflow on /dev/null, please empty the bit bucket.
d985c78
d985c78
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d985c78
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d985c78
\\\        download, build and distribute -- http://www.A-A-P.org        ///
d985c78
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///