Mercurial > vim
changeset 5464:9c777e2c7024 v7.4.082
updated for version 7.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.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 09 Nov 2013 03:31:51 +0100 |
parents | 3d194611edad |
children | f0bffd7a3293 |
files | src/ex_cmds.c src/ex_cmds2.c src/ex_docmd.c src/globals.h src/proto/ex_cmds2.pro src/version.c src/vim.h |
diffstat | 7 files changed, 53 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3253,8 +3253,10 @@ do_ecmd(fnum, ffname, sfname, eap, newln 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
--- 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, fo 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, fo 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;
--- 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();
--- a/src/globals.h +++ b/src/globals.h @@ -1490,6 +1490,7 @@ EXTERN char_u e_notmp[] INIT(= N_("E483 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"));
--- 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));
--- 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,
--- a/src/vim.h +++ b/src/vim.h @@ -1176,6 +1176,15 @@ extern char *(*dyn_libintl_textdomain)(c #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.