vim-patch:7.4.213

Problem:    It's not possible to open a new buffer without creating a swap
            file.
Solution:   Add the ":noswapfile" modifier. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=e25a04c1c515e6eb32197291472f89bcadfabf89
This commit is contained in:
oni-link 2014-04-14 22:40:49 +02:00 committed by Thiago de Arruda
parent 965f587061
commit 824d64cb18
4 changed files with 33 additions and 13 deletions

View File

@ -639,6 +639,8 @@ enum CMD_index
EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN), EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
EX(CMD_noremenu, "noremenu", ex_menu, EX(CMD_noremenu, "noremenu", ex_menu,
RANGE|NOTADR|ZEROR|BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN), RANGE|NOTADR|ZEROR|BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
EX(CMD_noswapfile, "noswapfile", ex_wrongmodifier,
NEEDARG|EXTRA|NOTRLCOM),
EX(CMD_normal, "normal", ex_normal, EX(CMD_normal, "normal", ex_normal,
RANGE|BANG|EXTRA|NEEDARG|NOTRLCOM|USECTRLV|SBOXOK|CMDWIN), RANGE|BANG|EXTRA|NEEDARG|NOTRLCOM|USECTRLV|SBOXOK|CMDWIN),
EX(CMD_number, "number", ex_print, EX(CMD_number, "number", ex_print,
@ -1183,6 +1185,7 @@ typedef struct {
int keepjumps; /* TRUE when ":keepjumps" was used */ int keepjumps; /* TRUE when ":keepjumps" was used */
int lockmarks; /* TRUE when ":lockmarks" was used */ int lockmarks; /* TRUE when ":lockmarks" was used */
int keeppatterns; /* TRUE when ":keeppatterns" was used */ int keeppatterns; /* TRUE when ":keeppatterns" was used */
bool noswapfile; /* true when ":noswapfile" was used */
char_u *save_ei; /* saved value of 'eventignore' */ char_u *save_ei; /* saved value of 'eventignore' */
} cmdmod_T; } cmdmod_T;

View File

@ -1400,16 +1400,22 @@ void *cookie; /*argument for fgetline() */
cmdmod.split |= WSP_ABOVE; cmdmod.split |= WSP_ABOVE;
continue; continue;
case 'n': if (!checkforcmd(&ea.cmd, "noautocmd", 3)) case 'n':
break; if (checkforcmd(&ea.cmd, "noautocmd", 3)) {
if (cmdmod.save_ei == NULL) { if (cmdmod.save_ei == NULL) {
/* Set 'eventignore' to "all". Restore the /* Set 'eventignore' to "all". Restore the
* existing option value later. */ * existing option value later. */
cmdmod.save_ei = vim_strsave(p_ei); cmdmod.save_ei = vim_strsave(p_ei);
set_string_option_direct((char_u *)"ei", -1, set_string_option_direct(
(char_u *)"all", OPT_FREE, SID_NONE); (char_u *)"ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
} }
continue; continue;
}
if (!checkforcmd(&ea.cmd, "noswapfile", 6)) {
break;
}
cmdmod.noswapfile = true;
continue;
case 'r': if (!checkforcmd(&ea.cmd, "rightbelow", 6)) case 'r': if (!checkforcmd(&ea.cmd, "rightbelow", 6))
break; break;
@ -1991,6 +1997,8 @@ void *cookie; /*argument for fgetline() */
case CMD_let: case CMD_let:
case CMD_lockmarks: case CMD_lockmarks:
case CMD_match: case CMD_match:
case CMD_noautocmd:
case CMD_noswapfile:
case CMD_psearch: case CMD_psearch:
case CMD_return: case CMD_return:
case CMD_rightbelow: case CMD_rightbelow:
@ -2414,6 +2422,7 @@ static struct cmdmod {
{"leftabove", 5, FALSE}, {"leftabove", 5, FALSE},
{"lockmarks", 3, FALSE}, {"lockmarks", 3, FALSE},
{"noautocmd", 3, FALSE}, {"noautocmd", 3, FALSE},
{"noswapfile", 3, FALSE},
{"rightbelow", 6, FALSE}, {"rightbelow", 6, FALSE},
{"sandbox", 3, FALSE}, {"sandbox", 3, FALSE},
{"silent", 3, FALSE}, {"silent", 3, FALSE},
@ -2851,6 +2860,8 @@ set_one_cmd_context (
case CMD_keeppatterns: case CMD_keeppatterns:
case CMD_leftabove: case CMD_leftabove:
case CMD_lockmarks: case CMD_lockmarks:
case CMD_noautocmd:
case CMD_noswapfile:
case CMD_rightbelow: case CMD_rightbelow:
case CMD_sandbox: case CMD_sandbox:
case CMD_silent: case CMD_silent:

View File

@ -296,6 +296,10 @@ int ml_open(buf_T *buf)
buf->b_ml.ml_line_lnum = 0; /* no cached line */ buf->b_ml.ml_line_lnum = 0; /* no cached line */
buf->b_ml.ml_chunksize = NULL; buf->b_ml.ml_chunksize = NULL;
if (cmdmod.noswapfile) {
buf->b_p_swf = FALSE;
}
/* /*
* When 'updatecount' is non-zero swap file may be opened later. * When 'updatecount' is non-zero swap file may be opened later.
*/ */
@ -563,8 +567,9 @@ void ml_setname(buf_T *buf)
* When 'updatecount' is 0 and 'noswapfile' there is no swap file. * When 'updatecount' is 0 and 'noswapfile' there is no swap file.
* For help files we will make a swap file now. * For help files we will make a swap file now.
*/ */
if (p_uc != 0) if (p_uc != 0 && !cmdmod.noswapfile) {
ml_open_file(buf); /* create a swap file */ ml_open_file(buf); /* create a swap file */
}
return; return;
} }
@ -652,8 +657,9 @@ void ml_open_file(buf_T *buf)
char_u *dirp; char_u *dirp;
mfp = buf->b_ml.ml_mfp; mfp = buf->b_ml.ml_mfp;
if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf) if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf || cmdmod.noswapfile) {
return; /* nothing to do */ return; /* nothing to do */
}
/* For a spell buffer use a temp file name. */ /* For a spell buffer use a temp file name. */
if (buf->b_spell) { if (buf->b_spell) {

View File

@ -248,7 +248,7 @@ static int included_patches[] = {
//216, //216,
//215, //215,
//214, //214,
//213, 213,
//212, //212,
//211, //211,
210, 210,