aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2014-04-14 22:40:49 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-14 18:23:57 -0300
commit824d64cb185495f7aada32d7a63710916d448175 (patch)
treeb0cec2b3ff607462245c2d53a262d328116d56d9
parent965f5870616ae6a31779ddce4f74ae4f1b564979 (diff)
downloadrneovim-824d64cb185495f7aada32d7a63710916d448175.tar.gz
rneovim-824d64cb185495f7aada32d7a63710916d448175.tar.bz2
rneovim-824d64cb185495f7aada32d7a63710916d448175.zip
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
-rw-r--r--src/ex_cmds_defs.h3
-rw-r--r--src/ex_docmd.c25
-rw-r--r--src/memline.c14
-rw-r--r--src/version.c2
4 files changed, 32 insertions, 12 deletions
diff --git a/src/ex_cmds_defs.h b/src/ex_cmds_defs.h
index 739286fc5c..3ef1021135 100644
--- a/src/ex_cmds_defs.h
+++ b/src/ex_cmds_defs.h
@@ -639,6 +639,8 @@ enum CMD_index
EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
EX(CMD_noremenu, "noremenu", ex_menu,
RANGE|NOTADR|ZEROR|BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
+ EX(CMD_noswapfile, "noswapfile", ex_wrongmodifier,
+ NEEDARG|EXTRA|NOTRLCOM),
EX(CMD_normal, "normal", ex_normal,
RANGE|BANG|EXTRA|NEEDARG|NOTRLCOM|USECTRLV|SBOXOK|CMDWIN),
EX(CMD_number, "number", ex_print,
@@ -1183,6 +1185,7 @@ typedef struct {
int keepjumps; /* TRUE when ":keepjumps" was used */
int lockmarks; /* TRUE when ":lockmarks" was used */
int keeppatterns; /* TRUE when ":keeppatterns" was used */
+ bool noswapfile; /* true when ":noswapfile" was used */
char_u *save_ei; /* saved value of 'eventignore' */
} cmdmod_T;
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index e8064b1109..402ea989a0 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1400,15 +1400,21 @@ void *cookie; /*argument for fgetline() */
cmdmod.split |= WSP_ABOVE;
continue;
- case 'n': if (!checkforcmd(&ea.cmd, "noautocmd", 3))
+ case 'n':
+ if (checkforcmd(&ea.cmd, "noautocmd", 3)) {
+ if (cmdmod.save_ei == NULL) {
+ /* Set 'eventignore' to "all". Restore the
+ * existing option value later. */
+ cmdmod.save_ei = vim_strsave(p_ei);
+ set_string_option_direct(
+ (char_u *)"ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
+ }
+ continue;
+ }
+ if (!checkforcmd(&ea.cmd, "noswapfile", 6)) {
break;
- if (cmdmod.save_ei == NULL) {
- /* Set 'eventignore' to "all". Restore the
- * existing option value later. */
- cmdmod.save_ei = vim_strsave(p_ei);
- set_string_option_direct((char_u *)"ei", -1,
- (char_u *)"all", OPT_FREE, SID_NONE);
}
+ cmdmod.noswapfile = true;
continue;
case 'r': if (!checkforcmd(&ea.cmd, "rightbelow", 6))
@@ -1991,6 +1997,8 @@ void *cookie; /*argument for fgetline() */
case CMD_let:
case CMD_lockmarks:
case CMD_match:
+ case CMD_noautocmd:
+ case CMD_noswapfile:
case CMD_psearch:
case CMD_return:
case CMD_rightbelow:
@@ -2414,6 +2422,7 @@ static struct cmdmod {
{"leftabove", 5, FALSE},
{"lockmarks", 3, FALSE},
{"noautocmd", 3, FALSE},
+ {"noswapfile", 3, FALSE},
{"rightbelow", 6, FALSE},
{"sandbox", 3, FALSE},
{"silent", 3, FALSE},
@@ -2851,6 +2860,8 @@ set_one_cmd_context (
case CMD_keeppatterns:
case CMD_leftabove:
case CMD_lockmarks:
+ case CMD_noautocmd:
+ case CMD_noswapfile:
case CMD_rightbelow:
case CMD_sandbox:
case CMD_silent:
diff --git a/src/memline.c b/src/memline.c
index 469518d70c..1852682cb1 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -296,6 +296,10 @@ int ml_open(buf_T *buf)
buf->b_ml.ml_line_lnum = 0; /* no cached line */
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.
*/
@@ -563,8 +567,9 @@ void ml_setname(buf_T *buf)
* When 'updatecount' is 0 and 'noswapfile' there is no swap file.
* For help files we will make a swap file now.
*/
- if (p_uc != 0)
- ml_open_file(buf); /* create a swap file */
+ if (p_uc != 0 && !cmdmod.noswapfile) {
+ ml_open_file(buf); /* create a swap file */
+ }
return;
}
@@ -652,8 +657,9 @@ void ml_open_file(buf_T *buf)
char_u *dirp;
mfp = buf->b_ml.ml_mfp;
- if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf)
- return; /* nothing to do */
+ if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf || cmdmod.noswapfile) {
+ return; /* nothing to do */
+ }
/* For a spell buffer use a temp file name. */
if (buf->b_spell) {
diff --git a/src/version.c b/src/version.c
index e5cdd76ebd..39f915a261 100644
--- a/src/version.c
+++ b/src/version.c
@@ -248,7 +248,7 @@ static int included_patches[] = {
//216,
//215,
//214,
- //213,
+ 213,
//212,
//211,
210,