updated for version 7.0-087
diff --git a/src/buffer.c b/src/buffer.c
index 3359bc2..e05bd39 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -434,12 +434,8 @@
if (usingNetbeans)
netbeans_file_closed(buf);
#endif
-#ifdef FEAT_AUTOCHDIR
- /* Change directories when the acd option is set on. */
- if (p_acd && curbuf->b_ffname != NULL
- && vim_chdirfile(curbuf->b_ffname) == OK)
- shorten_fnames(TRUE);
-#endif
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
/*
* Remove the buffer from the list.
@@ -1422,12 +1418,8 @@
netbeans_file_activated(curbuf);
#endif
-#ifdef FEAT_AUTOCHDIR
- /* Change directories when the acd option is set on. */
- if (p_acd && curbuf->b_ffname != NULL
- && vim_chdirfile(curbuf->b_ffname) == OK)
- shorten_fnames(TRUE);
-#endif
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
#ifdef FEAT_KEYMAP
if (curbuf->b_kmap_state & KEYMAP_INIT)
@@ -1436,6 +1428,18 @@
redraw_later(NOT_VALID);
}
+#if defined(FEAT_AUTOCHDIR) || defined(PROTO)
+/*
+ * Change to the directory of the current buffer.
+ */
+ void
+do_autochdir()
+{
+ if (curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK)
+ shorten_fnames(TRUE);
+}
+#endif
+
/*
* functions for dealing with the buffer list
*/
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 7044073..074abfd 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2458,6 +2458,8 @@
#ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
#endif
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
}
/* print full file name if :cd used */
fileinfo(FALSE, FALSE, eap->forceit);
@@ -2675,8 +2677,13 @@
eap, eap->append, eap->forceit, TRUE, FALSE);
/* After ":saveas fname" reset 'readonly'. */
- if (eap->cmdidx == CMD_saveas && retval == OK)
- curbuf->b_p_ro = FALSE;
+ if (eap->cmdidx == CMD_saveas)
+ {
+ if (retval == OK)
+ curbuf->b_p_ro = FALSE;
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
+ }
}
theend:
@@ -3547,11 +3554,9 @@
foldUpdateAll(curwin);
#endif
-#ifdef FEAT_AUTOCHDIR
- if (p_acd && curbuf->b_ffname != NULL
- && vim_chdirfile(curbuf->b_ffname) == OK)
- shorten_fnames(TRUE);
-#endif
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
+
/*
* Careful: open_buffer() and apply_autocmds() may change the current
* buffer and window.
@@ -3718,12 +3723,8 @@
if (p_im)
need_start_insertmode = TRUE;
-#ifdef FEAT_AUTOCHDIR
- /* Change directories when the acd option is set on. */
- if (p_acd && curbuf->b_ffname != NULL
- && vim_chdirfile(curbuf->b_ffname) == OK)
- shorten_fnames(TRUE);
-#endif
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
if (gui.in_use && curbuf->b_ffname != NULL)
diff --git a/src/macros.h b/src/macros.h
index c4c9a14..a8bc2b8 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -276,3 +276,9 @@
# define MB_CHARLEN(p) STRLEN(p)
# define PTR2CHAR(p) ((int)*(p))
#endif
+
+#ifdef FEAT_AUTOCHDIR
+# define DO_AUTOCHDIR if (p_acd) do_autochdir();
+#else
+# define DO_AUTOCHDIR
+#endif
diff --git a/src/option.c b/src/option.c
index c599d02..1f47c60 100644
--- a/src/option.c
+++ b/src/option.c
@@ -7326,9 +7326,8 @@
#ifdef FEAT_AUTOCHDIR
else if ((int *)varp == &p_acd)
{
- if (p_acd && curbuf->b_ffname != NULL
- && vim_chdirfile(curbuf->b_ffname) == OK)
- shorten_fnames(TRUE);
+ /* Change directories when the 'acd' option is set now. */
+ DO_AUTOCHDIR
}
#endif
diff --git a/src/proto/buffer.pro b/src/proto/buffer.pro
index 9da8c3e..d0556b6 100644
--- a/src/proto/buffer.pro
+++ b/src/proto/buffer.pro
@@ -10,6 +10,7 @@
extern int do_buffer __ARGS((int action, int start, int dir, int count, int forceit));
extern void set_curbuf __ARGS((buf_T *buf, int action));
extern void enter_buffer __ARGS((buf_T *buf));
+extern void do_autochdir __ARGS((void));
extern buf_T *buflist_new __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum, int flags));
extern void free_buf_options __ARGS((buf_T *buf, int free_p_ff));
extern int buflist_getfile __ARGS((int n, linenr_T lnum, int options, int forceit));
diff --git a/src/version.c b/src/version.c
index 21eb870..21a904a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 87,
+/**/
86,
/**/
85,
diff --git a/src/window.c b/src/window.c
index 4d09ad6..0300b55 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3954,13 +3954,8 @@
setmouse(); /* in case jumped to/from help buffer */
#endif
-#ifdef FEAT_AUTOCHDIR
- /* Change directories when the 'acd' option is set on and after
- * switching windows. */
- if (p_acd && curbuf->b_ffname != NULL
- && vim_chdirfile(curbuf->b_ffname) == OK)
- shorten_fnames(TRUE);
-#endif
+ /* Change directories when the 'acd' option is set. */
+ DO_AUTOCHDIR
}
#endif /* FEAT_WINDOWS */