]> granicus.if.org Git - vim/commitdiff
patch 8.2.0641: Vim9: not expanded in :hardcopy and syn-include v8.2.0641
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Apr 2020 11:50:41 +0000 (13:50 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Apr 2020 11:50:41 +0000 (13:50 +0200)
Problem:    Vim9:  not expanded in :hardcopy and "syntax include".
Solution:   Add the EX_EXPAND flag.  Expend "syntax include".

src/ex_cmds.h
src/testdir/test_vim9_cmd.vim
src/version.c
src/vim9compile.c
src/vim9execute.c

index 0c158e1bd58524bfc8d5c45ccc2033192516fb61..25a0853bda61365778a3c2b3ee39587e6c9d6b93 100644 (file)
@@ -53,6 +53,8 @@
 #define EX_MODIFY    0x100000  // forbidden in non-'modifiable' buffer
 #define EX_FLAGS     0x200000  // allow flags after count in argument
 #define EX_RESTRICT  0x400000  // forbidden in restricted mode
+#define EX_EXPAND    0x800000  // expands wildcards later
+
 #define EX_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed
 #define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file
 #define EX_WORD1 (EX_EXTRA | EX_NOSPC) // one extra word allowed
@@ -653,7 +655,7 @@ EXCMD(CMD_helptags, "helptags",     ex_helptags,
        EX_NEEDARG|EX_FILES|EX_TRLBAR|EX_CMDWIN,
        ADDR_NONE),
 EXCMD(CMD_hardcopy,    "hardcopy",     ex_hardcopy,
-       EX_RANGE|EX_COUNT|EX_EXTRA|EX_TRLBAR|EX_DFLALL|EX_BANG,
+       EX_RANGE|EX_COUNT|EX_EXTRA|EX_EXPAND|EX_TRLBAR|EX_DFLALL|EX_BANG,
        ADDR_LINES),
 EXCMD(CMD_highlight,   "highlight",    ex_highlight,
        EX_BANG|EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN,
index 7ccd1f70cc9af207b67b07b4c59b3cd4d8bc2edf..70437b901f70f6c11279f8b2a24acc07a7bb7573 100644 (file)
@@ -1,5 +1,6 @@
 " Test commands that are not compiled in a :def function
 
+source check.vim
 source vim9.vim
 
 def Test_edit_wildcards()
@@ -19,5 +20,29 @@ def Test_edit_wildcards()
   assert_equal('XXtestxx77yy', bufname())
 enddef
 
+def Test_hardcopy_wildcards()
+  CheckUnix
+  CheckFeature postscript
+
+  let outfile = 'print'
+  hardcopy > X`=outfile`.ps
+  assert_true(filereadable('Xprint.ps'))
+
+  delete('Xprint.ps')
+enddef
+
+def Test_syn_include_wildcards()
+  writefile(['syn keyword Found found'], 'Xthemine.vim')
+  let save_rtp = &rtp
+  &rtp = '.'
+
+  let fname = 'mine'
+  syn include @Group Xthe`=fname`.vim
+  assert_match('Found.* contained found', execute('syn list Found'))
+
+  &rtp = save_rtp
+  delete('Xthemine.vim')
+enddef
+
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index 233106b2468200ee10feb9607e2819379c6a737f..3829af5b3fc503a1596827ea593473f97f7512b0 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    641,
 /**/
     640,
 /**/
index 092939e08d6541059f10becc88a8e64cb6b2e108..ccd73f77fa9fa026e005c0aad0b2f458b1982cef 100644 (file)
@@ -5821,14 +5821,23 @@ compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
     static char_u *
 compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
 {
-    char_u *p;
+    char_u  *p;
+    int            has_expr;
 
     if (cctx->ctx_skip == TRUE)
        goto theend;
 
+    has_expr = (excmd_get_argt(eap->cmdidx) & (EX_XFILE | EX_EXPAND));
+    if (eap->cmdidx == CMD_syntax && STRNCMP(eap->arg, "include ", 8) == 0)
+    {
+       // expand filename in "syntax include [@group] filename"
+       has_expr = TRUE;
+       eap->arg = skipwhite(eap->arg + 7);
+       if (*eap->arg == '@')
+           eap->arg = skiptowhite(eap->arg);
+    }
 
-    if ((excmd_get_argt(eap->cmdidx) & EX_XFILE)
-           && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
+    if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
     {
        int     count = 0;
        char_u  *start = skipwhite(line);
index 7172718c29621d90148639d894efb1862df88d8e..9ea7dafad3535706e54a6082ebe75320239a950f 100644 (file)
@@ -645,6 +645,7 @@ call_def_function(
        {
            // execute Ex command line
            case ISN_EXEC:
+               SOURCING_LNUM = iptr->isn_lnum;
                do_cmdline_cmd(iptr->isn_arg.string);
                break;
 
@@ -682,6 +683,7 @@ call_def_function(
                        }
                    }
 
+                   SOURCING_LNUM = iptr->isn_lnum;
                    do_cmdline_cmd(cmd);
                    vim_free(cmd);
                }