diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-11-09 03:31:51 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-11-09 03:31:51 +0100 |
commit | 45d3b1454c1001001ef97746556d3142788a8383 (patch) | |
tree | 7978ed006e36ad2984ec3afda7b1027b8f4dca30 | |
parent | 815135e4082dce22a264cc1f176187221d5313cf (diff) | |
download | vim-git-45d3b1454c1001001ef97746556d3142788a8383.tar.gz |
updated for version 7.4.082v7.4.082
Problem: Using "gf" in a changed buffer suggests adding "!", which is not
possible. (Tim Chase)
Solution: Pass a flag to check_changed() wether adding ! make sense.
-rw-r--r-- | src/ex_cmds.c | 8 | ||||
-rw-r--r-- | src/ex_cmds2.c | 40 | ||||
-rw-r--r-- | src/ex_docmd.c | 12 | ||||
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/proto/ex_cmds2.pro | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 9 |
7 files changed, 53 insertions, 21 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 76cc8f6d2..8f85911ba 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3253,8 +3253,10 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin) if ( ((!other_file && !(flags & ECMD_OLDBUF)) || (curbuf->b_nwindows == 1 && !(flags & (ECMD_HIDE | ECMD_ADDBUF)))) - && check_changed(curbuf, p_awa, !other_file, - (flags & ECMD_FORCEIT), FALSE)) + && check_changed(curbuf, (p_awa ? CCGD_AW : 0) + | (other_file ? 0 : CCGD_MULTWIN) + | ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0) + | (eap == NULL ? 0 : CCGD_EXCMD))) { if (fnum == 0 && other_file && ffname != NULL) (void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum); @@ -7664,7 +7666,7 @@ ex_drop(eap) # ifdef FEAT_WINDOWS ++emsg_off; # endif - split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE); + split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD); # ifdef FEAT_WINDOWS --emsg_off; # else diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 4a860ca88..e66d4c571 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1436,20 +1436,20 @@ autowrite_all() } /* - * return TRUE if buffer was changed and cannot be abandoned. + * Return TRUE if buffer was changed and cannot be abandoned. + * For flags use the CCGD_ values. */ int -check_changed(buf, checkaw, mult_win, forceit, allbuf) +check_changed(buf, flags) buf_T *buf; - int checkaw; /* do autowrite if buffer was changed */ - int mult_win; /* check also when several wins for the buf */ - int forceit; - int allbuf UNUSED; /* may write all buffers */ + int flags; { + int forceit = (flags & CCGD_FORCEIT); + if ( !forceit && bufIsChanged(buf) - && (mult_win || buf->b_nwindows <= 1) - && (!checkaw || autowrite(buf, forceit) == FAIL)) + && ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1) + && (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL)) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && p_write) @@ -1457,7 +1457,7 @@ check_changed(buf, checkaw, mult_win, forceit, allbuf) buf_T *buf2; int count = 0; - if (allbuf) + if (flags & CCGD_ALLBUF) for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) if (bufIsChanged(buf2) && (buf2->b_ffname != NULL @@ -1480,7 +1480,10 @@ check_changed(buf, checkaw, mult_win, forceit, allbuf) return bufIsChanged(buf); } #endif - EMSG(_(e_nowrtmsg)); + if (flags & CCGD_EXCMD) + EMSG(_(e_nowrtmsg)); + else + EMSG(_(e_nowrtmsg_nobang)); return TRUE; } return FALSE; @@ -1690,7 +1693,9 @@ check_changed_any(hidden) { /* Try auto-writing the buffer. If this fails but the buffer no * longer exists it's not changed, that's OK. */ - if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf)) + if (check_changed(buf, (p_awa ? CCGD_AW : 0) + | CCGD_MULTWIN + | CCGD_ALLBUF) && buf_valid(buf)) break; /* didn't save - still changes */ } } @@ -2274,7 +2279,10 @@ do_argfile(eap, argn) vim_free(p); } if ((!P_HID(curbuf) || !other) - && check_changed(curbuf, TRUE, !other, eap->forceit, FALSE)) + && check_changed(curbuf, CCGD_AW + | (other ? 0 : CCGD_MULTWIN) + | (eap->forceit ? CCGD_FORCEIT : 0) + | CCGD_EXCMD)) return; } @@ -2315,7 +2323,9 @@ ex_next(eap) */ if ( P_HID(curbuf) || eap->cmdidx == CMD_snext - || !check_changed(curbuf, TRUE, FALSE, eap->forceit, FALSE)) + || !check_changed(curbuf, CCGD_AW + | (eap->forceit ? CCGD_FORCEIT : 0) + | CCGD_EXCMD)) { if (*eap->arg != NUL) /* redefine file list */ { @@ -2458,7 +2468,9 @@ ex_listdo(eap) if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo || P_HID(curbuf) - || !check_changed(curbuf, TRUE, FALSE, eap->forceit, FALSE)) + || !check_changed(curbuf, CCGD_AW + | (eap->forceit ? CCGD_FORCEIT : 0) + | CCGD_EXCMD)) { /* start at the first argument/window/buffer */ i = 0; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 5d207ea80..8d06a95c9 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -6565,7 +6565,9 @@ ex_quit(eap) if (check_more(FALSE, eap->forceit) == OK && only_one_window()) exiting = TRUE; if ((!P_HID(curbuf) - && check_changed(curbuf, p_awa, FALSE, eap->forceit, FALSE)) + && check_changed(curbuf, (p_awa ? CCGD_AW : 0) + | (eap->forceit ? CCGD_FORCEIT : 0) + | CCGD_EXCMD)) || check_more(TRUE, eap->forceit) == FAIL || (only_one_window() && check_changed_any(eap->forceit))) { @@ -7099,7 +7101,7 @@ handle_drop(filec, filev, split) if (!P_HID(curbuf) && !split) { ++emsg_off; - split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE); + split = check_changed(curbuf, CCGD_AW); --emsg_off; } if (split) @@ -7361,7 +7363,11 @@ ex_recover(eap) { /* Set recoverymode right away to avoid the ATTENTION prompt. */ recoverymode = TRUE; - if (!check_changed(curbuf, p_awa, TRUE, eap->forceit, FALSE) + if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) + | CCGD_MULTWIN + | (eap->forceit ? CCGD_FORCEIT : 0) + | CCGD_EXCMD) + && (*eap->arg == NUL || setfname(curbuf, eap->arg, NULL, TRUE) == OK)) ml_recover(); diff --git a/src/globals.h b/src/globals.h index feb1dd457..916f7e31b 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1490,6 +1490,7 @@ EXTERN char_u e_notmp[] INIT(= N_("E483: Can't get temp file name")); EXTERN char_u e_notopen[] INIT(= N_("E484: Can't open file %s")); EXTERN char_u e_notread[] INIT(= N_("E485: Can't read file %s")); EXTERN char_u e_nowrtmsg[] INIT(= N_("E37: No write since last change (add ! to override)")); +EXTERN char_u e_nowrtmsg_nobang[] INIT(= N_("E37: No write since last change")); EXTERN char_u e_null[] INIT(= N_("E38: Null argument")); #ifdef FEAT_DIGRAPHS EXTERN char_u e_number_exp[] INIT(= N_("E39: Number expected")); diff --git a/src/proto/ex_cmds2.pro b/src/proto/ex_cmds2.pro index d30ba41ef..0ac3e1492 100644 --- a/src/proto/ex_cmds2.pro +++ b/src/proto/ex_cmds2.pro @@ -35,7 +35,7 @@ void prof_inchar_exit __ARGS((void)); int prof_def_func __ARGS((void)); int autowrite __ARGS((buf_T *buf, int forceit)); void autowrite_all __ARGS((void)); -int check_changed __ARGS((buf_T *buf, int checkaw, int mult_win, int forceit, int allbuf)); +int check_changed __ARGS((buf_T *buf, int flags)); void browse_save_fname __ARGS((buf_T *buf)); void dialog_changed __ARGS((buf_T *buf, int checkall)); int can_abandon __ARGS((buf_T *buf, int forceit)); diff --git a/src/version.c b/src/version.c index fdde4a9fa..e4b039e31 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 82, +/**/ 81, /**/ 80, @@ -1176,6 +1176,15 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname); #define RESIZE_BOTH 15 /* resize in both directions */ /* + * flags for check_changed() + */ +#define CCGD_AW 1 /* do autowrite if buffer was changed */ +#define CCGD_MULTWIN 2 /* check also when several wins for the buf */ +#define CCGD_FORCEIT 4 /* ! used */ +#define CCGD_ALLBUF 8 /* may write all buffers */ +#define CCGD_EXCMD 16 /* may suggest using ! */ + +/* * "flags" values for option-setting functions. * When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global * values, get local value. |