0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.0-087

This commit is contained in:
Bram Moolenaar 2006-09-05 14:31:54 +00:00
parent 53ed192b3c
commit 498efdb7f6
7 changed files with 43 additions and 35 deletions

View File

@ -434,12 +434,8 @@ close_buffer(win, buf, action)
if (usingNetbeans) if (usingNetbeans)
netbeans_file_closed(buf); netbeans_file_closed(buf);
#endif #endif
#ifdef FEAT_AUTOCHDIR /* Change directories when the 'acd' option is set. */
/* Change directories when the acd option is set on. */ DO_AUTOCHDIR
if (p_acd && curbuf->b_ffname != NULL
&& vim_chdirfile(curbuf->b_ffname) == OK)
shorten_fnames(TRUE);
#endif
/* /*
* Remove the buffer from the list. * Remove the buffer from the list.
@ -1422,12 +1418,8 @@ enter_buffer(buf)
netbeans_file_activated(curbuf); netbeans_file_activated(curbuf);
#endif #endif
#ifdef FEAT_AUTOCHDIR /* Change directories when the 'acd' option is set. */
/* Change directories when the acd option is set on. */ DO_AUTOCHDIR
if (p_acd && curbuf->b_ffname != NULL
&& vim_chdirfile(curbuf->b_ffname) == OK)
shorten_fnames(TRUE);
#endif
#ifdef FEAT_KEYMAP #ifdef FEAT_KEYMAP
if (curbuf->b_kmap_state & KEYMAP_INIT) if (curbuf->b_kmap_state & KEYMAP_INIT)
@ -1436,6 +1428,18 @@ enter_buffer(buf)
redraw_later(NOT_VALID); 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 * functions for dealing with the buffer list
*/ */

View File

@ -2458,6 +2458,8 @@ ex_file(eap)
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
#endif #endif
/* Change directories when the 'acd' option is set. */
DO_AUTOCHDIR
} }
/* print full file name if :cd used */ /* print full file name if :cd used */
fileinfo(FALSE, FALSE, eap->forceit); fileinfo(FALSE, FALSE, eap->forceit);
@ -2675,8 +2677,13 @@ do_write(eap)
eap, eap->append, eap->forceit, TRUE, FALSE); eap, eap->append, eap->forceit, TRUE, FALSE);
/* After ":saveas fname" reset 'readonly'. */ /* After ":saveas fname" reset 'readonly'. */
if (eap->cmdidx == CMD_saveas && retval == OK) if (eap->cmdidx == CMD_saveas)
curbuf->b_p_ro = FALSE; {
if (retval == OK)
curbuf->b_p_ro = FALSE;
/* Change directories when the 'acd' option is set. */
DO_AUTOCHDIR
}
} }
theend: theend:
@ -3547,11 +3554,9 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
foldUpdateAll(curwin); foldUpdateAll(curwin);
#endif #endif
#ifdef FEAT_AUTOCHDIR /* Change directories when the 'acd' option is set. */
if (p_acd && curbuf->b_ffname != NULL DO_AUTOCHDIR
&& vim_chdirfile(curbuf->b_ffname) == OK)
shorten_fnames(TRUE);
#endif
/* /*
* Careful: open_buffer() and apply_autocmds() may change the current * Careful: open_buffer() and apply_autocmds() may change the current
* buffer and window. * buffer and window.
@ -3718,12 +3723,8 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
if (p_im) if (p_im)
need_start_insertmode = TRUE; need_start_insertmode = TRUE;
#ifdef FEAT_AUTOCHDIR /* Change directories when the 'acd' option is set. */
/* Change directories when the acd option is set on. */ DO_AUTOCHDIR
if (p_acd && curbuf->b_ffname != NULL
&& vim_chdirfile(curbuf->b_ffname) == OK)
shorten_fnames(TRUE);
#endif
#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
if (gui.in_use && curbuf->b_ffname != NULL) if (gui.in_use && curbuf->b_ffname != NULL)

View File

@ -276,3 +276,9 @@
# define MB_CHARLEN(p) STRLEN(p) # define MB_CHARLEN(p) STRLEN(p)
# define PTR2CHAR(p) ((int)*(p)) # define PTR2CHAR(p) ((int)*(p))
#endif #endif
#ifdef FEAT_AUTOCHDIR
# define DO_AUTOCHDIR if (p_acd) do_autochdir();
#else
# define DO_AUTOCHDIR
#endif

View File

@ -7326,9 +7326,8 @@ set_bool_option(opt_idx, varp, value, opt_flags)
#ifdef FEAT_AUTOCHDIR #ifdef FEAT_AUTOCHDIR
else if ((int *)varp == &p_acd) else if ((int *)varp == &p_acd)
{ {
if (p_acd && curbuf->b_ffname != NULL /* Change directories when the 'acd' option is set now. */
&& vim_chdirfile(curbuf->b_ffname) == OK) DO_AUTOCHDIR
shorten_fnames(TRUE);
} }
#endif #endif

View File

@ -10,6 +10,7 @@ extern char_u *do_bufdel __ARGS((int command, char_u *arg, int addr_count, int s
extern int do_buffer __ARGS((int action, int start, int dir, int count, int forceit)); 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 set_curbuf __ARGS((buf_T *buf, int action));
extern void enter_buffer __ARGS((buf_T *buf)); 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 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 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)); extern int buflist_getfile __ARGS((int n, linenr_T lnum, int options, int forceit));

View File

@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
87,
/**/ /**/
86, 86,
/**/ /**/

View File

@ -3954,13 +3954,8 @@ win_enter_ext(wp, undo_sync, curwin_invalid)
setmouse(); /* in case jumped to/from help buffer */ setmouse(); /* in case jumped to/from help buffer */
#endif #endif
#ifdef FEAT_AUTOCHDIR /* Change directories when the 'acd' option is set. */
/* Change directories when the 'acd' option is set on and after DO_AUTOCHDIR
* switching windows. */
if (p_acd && curbuf->b_ffname != NULL
&& vim_chdirfile(curbuf->b_ffname) == OK)
shorten_fnames(TRUE);
#endif
} }
#endif /* FEAT_WINDOWS */ #endif /* FEAT_WINDOWS */