]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.213 v7.4.213
authorBram Moolenaar <Bram@vim.org>
Sun, 23 Mar 2014 15:04:02 +0000 (16:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Mar 2014 15:04:02 +0000 (16:04 +0100)
Problem:    It's not possible to open a new buffer without creating a swap
            file.
Solution:   Add the ":noswapfile" modifier. (Christian Brabandt)

runtime/doc/recover.txt
src/ex_cmds.h
src/ex_docmd.c
src/memline.c
src/structs.h
src/version.c

index 5fc09c0e72f00527a9b32e7e967a88d15dde717f..650feb208b6a1512a612b4251b4468b7486f3025 100644 (file)
@@ -81,7 +81,14 @@ the amount of memory used to be higher than given with 'maxmem' or
 'maxmemtot'.  And when making a change to a read-only file, the swap file is
 created anyway.
 
-The 'swapfile' option can be reset to avoid creating a swapfile.
+The 'swapfile' option can be reset to avoid creating a swapfile.  And the
+|:noswapfile| modifier can be used to not create a swapfile for a new buffer.
+
+:noswap[file]   {command}                      *:noswap* *:noswapfile*
+               Execute {command}. If it contains a command that loads a new
+               buffer, it will be loaded without creating a swapfile and the
+               'swapfile' option will be reset.  If a buffer already had a
+               swapfile it is not removed and 'swapfile' is not reset.
 
 
 Detecting an existing swap file ~
index fc3763c08818faf892513b407179e14ab043e029..41d3a642d39d76b619587770991276824430bf98 100644 (file)
@@ -655,6 +655,8 @@ EX(CMD_noreabbrev,  "noreabbrev",   ex_abbreviate,
                        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,
index 507de7d15ad0d416a0e748988f7c5ce5616eecdb..95c699d9891f4b1b7b32c36f4141f6303bcac5fa 100644 (file)
@@ -1874,18 +1874,23 @@ do_one_cmd(cmdlinep, sourcing,
 #endif
                        continue;
 
-           case 'n':   if (!checkforcmd(&ea.cmd, "noautocmd", 3))
-                           break;
-#ifdef FEAT_AUTOCMD
-                       if (cmdmod.save_ei == NULL)
+           case 'n':   if (checkforcmd(&ea.cmd, "noautocmd", 3))
                        {
-                           /* 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,
+#ifdef FEAT_AUTOCMD
+                           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);
-                       }
+                           }
 #endif
+                           continue;
+                       }
+                       if (!checkforcmd(&ea.cmd, "noswapfile", 6))
+                           break;
+                       cmdmod.noswapfile = TRUE;
                        continue;
 
            case 'r':   if (!checkforcmd(&ea.cmd, "rightbelow", 6))
@@ -2596,6 +2601,8 @@ do_one_cmd(cmdlinep, sourcing,
            case CMD_lua:
            case CMD_match:
            case CMD_mzscheme:
+           case CMD_noautocmd:
+           case CMD_noswapfile:
            case CMD_perl:
            case CMD_psearch:
            case CMD_python:
@@ -3099,6 +3106,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},
@@ -3611,6 +3619,8 @@ set_one_cmd_context(xp, buff)
        case CMD_keeppatterns:
        case CMD_leftabove:
        case CMD_lockmarks:
+       case CMD_noautocmd:
+       case CMD_noswapfile:
        case CMD_rightbelow:
        case CMD_sandbox:
        case CMD_silent:
index 8f6c0e01e81eab1b627d14d6767abbef1731e203..fb438d273e1cbfae69251dba8dee1571af36d871 100644 (file)
@@ -289,6 +289,9 @@ ml_open(buf)
     buf->b_ml.ml_chunksize = NULL;
 #endif
 
+    if (cmdmod.noswapfile)
+       buf->b_p_swf = FALSE;
+
     /*
      * When 'updatecount' is non-zero swap file may be opened later.
      */
@@ -606,7 +609,7 @@ ml_setname(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)
+       if (p_uc != 0 && !cmdmod.noswapfile)
            ml_open_file(buf);      /* create a swap file */
        return;
     }
@@ -719,7 +722,7 @@ ml_open_file(buf)
     char_u     *dirp;
 
     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 */
 
 #ifdef FEAT_SPELL
index 7a3d69219f70b71f2bbe028a5d12b40c0f33ed2b..9bb35ceec1e40ea424cf290cbcbffd1837468b35 100644 (file)
@@ -545,6 +545,7 @@ typedef struct
     int                keepjumps;              /* TRUE when ":keepjumps" was used */
     int                lockmarks;              /* TRUE when ":lockmarks" was used */
     int                keeppatterns;           /* TRUE when ":keeppatterns" was used */
+    int                noswapfile;             /* TRUE when ":noswapfile" was used */
 # ifdef FEAT_AUTOCMD
     char_u     *save_ei;               /* saved value of 'eventignore' */
 # endif
index 36ff41f22330936310d762f1a5c570d8ca7d79d4..d8106a4313f801cffdaee5556b84a6aaa0408f46 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    213,
 /**/
     212,
 /**/