]> granicus.if.org Git - vim/commitdiff
patch 8.0.0655: not easy to make sure a function does not exist v8.0.0655
authorBram Moolenaar <Bram@vim.org>
Thu, 22 Jun 2017 17:15:24 +0000 (19:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 22 Jun 2017 17:15:24 +0000 (19:15 +0200)
Problem:    Not easy to make sure a function does not exist.
Solution:   Add ! as an optional argument to :delfunc.

src/ex_cmds.h
src/testdir/test_vimscript.vim
src/userfunc.c
src/version.c

index 531bd0e16f8be428a0af93665517ec8249c0ccd7..519cd0811edc2eb10f566094c829a1b97d383c00 100644 (file)
@@ -426,7 +426,7 @@ EX(CMD_delcommand,  "delcommand",   ex_delcommand,
                        NEEDARG|WORD1|TRLBAR|CMDWIN,
                        ADDR_LINES),
 EX(CMD_delfunction,    "delfunction",  ex_delfunction,
-                       NEEDARG|WORD1|CMDWIN,
+                       BANG|NEEDARG|WORD1|CMDWIN,
                        ADDR_LINES),
 EX(CMD_display,                "display",      ex_display,
                        EXTRA|NOTRLCOM|TRLBAR|SBOXOK|CMDWIN,
index 6f5a73fb862a39932fecc784b9654eef15cfbe29..c09e2343b6b00110593cb849e61d2d8a3f12f1a8 100644 (file)
@@ -1390,6 +1390,16 @@ func Test_endfunction_trailing()
     set verbose=0
 endfunc
 
+func Test_delfunction_force()
+    delfunc! Xtest
+    delfunc! Xtest
+    func Xtest()
+       echo 'nothing'
+    endfunc
+    delfunc! Xtest
+    delfunc! Xtest
+endfunc
+
 "-------------------------------------------------------------------------------
 " Modelines                                                                {{{1
 " vim: ts=8 sw=4 tw=80 fdm=marker
index de089bb68de1fab81ea213aba143796d39dc198f..34da2ef4b633f10d038b1094644bf8cd24f5351a 100644 (file)
@@ -2807,7 +2807,8 @@ ex_delfunction(exarg_T *eap)
     {
        if (fp == NULL)
        {
-           EMSG2(_(e_nofunc), eap->arg);
+           if (!eap->forceit)
+               EMSG2(_(e_nofunc), eap->arg);
            return;
        }
        if (fp->uf_calls > 0)
index 1e7d6486185caab4b1a43851eb20d0a3fda2408e..533660fa05048727112e3f34df43e72abe411de3 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    655,
 /**/
     654,
 /**/