Mirror of the Vim source from https://github.com/vim/vim
リビジョン | c06c658691e20f22ae95d4cf117057c7d0736308 (tree) |
---|---|
日時 | 2006-09-05 23:31:54 |
作者 | vimboss |
コミッター | vimboss |
updated for version 7.0-087
@@ -434,12 +434,8 @@ | ||
434 | 434 | if (usingNetbeans) |
435 | 435 | netbeans_file_closed(buf); |
436 | 436 | #endif |
437 | -#ifdef FEAT_AUTOCHDIR | |
438 | - /* Change directories when the acd option is set on. */ | |
439 | - if (p_acd && curbuf->b_ffname != NULL | |
440 | - && vim_chdirfile(curbuf->b_ffname) == OK) | |
441 | - shorten_fnames(TRUE); | |
442 | -#endif | |
437 | + /* Change directories when the 'acd' option is set. */ | |
438 | + DO_AUTOCHDIR | |
443 | 439 | |
444 | 440 | /* |
445 | 441 | * Remove the buffer from the list. |
@@ -1422,12 +1418,8 @@ | ||
1422 | 1418 | netbeans_file_activated(curbuf); |
1423 | 1419 | #endif |
1424 | 1420 | |
1425 | -#ifdef FEAT_AUTOCHDIR | |
1426 | - /* Change directories when the acd option is set on. */ | |
1427 | - if (p_acd && curbuf->b_ffname != NULL | |
1428 | - && vim_chdirfile(curbuf->b_ffname) == OK) | |
1429 | - shorten_fnames(TRUE); | |
1430 | -#endif | |
1421 | + /* Change directories when the 'acd' option is set. */ | |
1422 | + DO_AUTOCHDIR | |
1431 | 1423 | |
1432 | 1424 | #ifdef FEAT_KEYMAP |
1433 | 1425 | if (curbuf->b_kmap_state & KEYMAP_INIT) |
@@ -1436,6 +1428,18 @@ | ||
1436 | 1428 | redraw_later(NOT_VALID); |
1437 | 1429 | } |
1438 | 1430 | |
1431 | +#if defined(FEAT_AUTOCHDIR) || defined(PROTO) | |
1432 | +/* | |
1433 | + * Change to the directory of the current buffer. | |
1434 | + */ | |
1435 | + void | |
1436 | +do_autochdir() | |
1437 | +{ | |
1438 | + if (curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK) | |
1439 | + shorten_fnames(TRUE); | |
1440 | +} | |
1441 | +#endif | |
1442 | + | |
1439 | 1443 | /* |
1440 | 1444 | * functions for dealing with the buffer list |
1441 | 1445 | */ |
@@ -2458,6 +2458,8 @@ | ||
2458 | 2458 | #ifdef FEAT_AUTOCMD |
2459 | 2459 | apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); |
2460 | 2460 | #endif |
2461 | + /* Change directories when the 'acd' option is set. */ | |
2462 | + DO_AUTOCHDIR | |
2461 | 2463 | } |
2462 | 2464 | /* print full file name if :cd used */ |
2463 | 2465 | fileinfo(FALSE, FALSE, eap->forceit); |
@@ -2675,8 +2677,13 @@ | ||
2675 | 2677 | eap, eap->append, eap->forceit, TRUE, FALSE); |
2676 | 2678 | |
2677 | 2679 | /* After ":saveas fname" reset 'readonly'. */ |
2678 | - if (eap->cmdidx == CMD_saveas && retval == OK) | |
2679 | - curbuf->b_p_ro = FALSE; | |
2680 | + if (eap->cmdidx == CMD_saveas) | |
2681 | + { | |
2682 | + if (retval == OK) | |
2683 | + curbuf->b_p_ro = FALSE; | |
2684 | + /* Change directories when the 'acd' option is set. */ | |
2685 | + DO_AUTOCHDIR | |
2686 | + } | |
2680 | 2687 | } |
2681 | 2688 | |
2682 | 2689 | theend: |
@@ -3547,11 +3554,9 @@ | ||
3547 | 3554 | foldUpdateAll(curwin); |
3548 | 3555 | #endif |
3549 | 3556 | |
3550 | -#ifdef FEAT_AUTOCHDIR | |
3551 | - if (p_acd && curbuf->b_ffname != NULL | |
3552 | - && vim_chdirfile(curbuf->b_ffname) == OK) | |
3553 | - shorten_fnames(TRUE); | |
3554 | -#endif | |
3557 | + /* Change directories when the 'acd' option is set. */ | |
3558 | + DO_AUTOCHDIR | |
3559 | + | |
3555 | 3560 | /* |
3556 | 3561 | * Careful: open_buffer() and apply_autocmds() may change the current |
3557 | 3562 | * buffer and window. |
@@ -3718,12 +3723,8 @@ | ||
3718 | 3723 | if (p_im) |
3719 | 3724 | need_start_insertmode = TRUE; |
3720 | 3725 | |
3721 | -#ifdef FEAT_AUTOCHDIR | |
3722 | - /* Change directories when the acd option is set on. */ | |
3723 | - if (p_acd && curbuf->b_ffname != NULL | |
3724 | - && vim_chdirfile(curbuf->b_ffname) == OK) | |
3725 | - shorten_fnames(TRUE); | |
3726 | -#endif | |
3726 | + /* Change directories when the 'acd' option is set. */ | |
3727 | + DO_AUTOCHDIR | |
3727 | 3728 | |
3728 | 3729 | #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) |
3729 | 3730 | if (gui.in_use && curbuf->b_ffname != NULL) |
@@ -276,3 +276,9 @@ | ||
276 | 276 | # define MB_CHARLEN(p) STRLEN(p) |
277 | 277 | # define PTR2CHAR(p) ((int)*(p)) |
278 | 278 | #endif |
279 | + | |
280 | +#ifdef FEAT_AUTOCHDIR | |
281 | +# define DO_AUTOCHDIR if (p_acd) do_autochdir(); | |
282 | +#else | |
283 | +# define DO_AUTOCHDIR | |
284 | +#endif |
@@ -7326,9 +7326,8 @@ | ||
7326 | 7326 | #ifdef FEAT_AUTOCHDIR |
7327 | 7327 | else if ((int *)varp == &p_acd) |
7328 | 7328 | { |
7329 | - if (p_acd && curbuf->b_ffname != NULL | |
7330 | - && vim_chdirfile(curbuf->b_ffname) == OK) | |
7331 | - shorten_fnames(TRUE); | |
7329 | + /* Change directories when the 'acd' option is set now. */ | |
7330 | + DO_AUTOCHDIR | |
7332 | 7331 | } |
7333 | 7332 | #endif |
7334 | 7333 |
@@ -10,6 +10,7 @@ | ||
10 | 10 | extern int do_buffer __ARGS((int action, int start, int dir, int count, int forceit)); |
11 | 11 | extern void set_curbuf __ARGS((buf_T *buf, int action)); |
12 | 12 | extern void enter_buffer __ARGS((buf_T *buf)); |
13 | +extern void do_autochdir __ARGS((void)); | |
13 | 14 | extern buf_T *buflist_new __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum, int flags)); |
14 | 15 | extern void free_buf_options __ARGS((buf_T *buf, int free_p_ff)); |
15 | 16 | extern int buflist_getfile __ARGS((int n, linenr_T lnum, int options, int forceit)); |
@@ -667,6 +667,8 @@ | ||
667 | 667 | static int included_patches[] = |
668 | 668 | { /* Add new patch number below this line */ |
669 | 669 | /**/ |
670 | + 87, | |
671 | +/**/ | |
670 | 672 | 86, |
671 | 673 | /**/ |
672 | 674 | 85, |
@@ -3954,13 +3954,8 @@ | ||
3954 | 3954 | setmouse(); /* in case jumped to/from help buffer */ |
3955 | 3955 | #endif |
3956 | 3956 | |
3957 | -#ifdef FEAT_AUTOCHDIR | |
3958 | - /* Change directories when the 'acd' option is set on and after | |
3959 | - * switching windows. */ | |
3960 | - if (p_acd && curbuf->b_ffname != NULL | |
3961 | - && vim_chdirfile(curbuf->b_ffname) == OK) | |
3962 | - shorten_fnames(TRUE); | |
3963 | -#endif | |
3957 | + /* Change directories when the 'acd' option is set. */ | |
3958 | + DO_AUTOCHDIR | |
3964 | 3959 | } |
3965 | 3960 | |
3966 | 3961 | #endif /* FEAT_WINDOWS */ |