# HG changeset patch # User Bram Moolenaar # Date 1587902404 -7200 # Node ID 1d84eaed0ec80f2693e3e465bd6a85053b534f23 # Parent 7e3f60fb4b3fa56b48ecba5e398e0b3bc5e67f6e patch 8.2.0641: Vim9: not expanded in :hardcopy and syn-include Commit: https://github.com/vim/vim/commit/6378c4fef37df05c99e8a43616063b4ddb692876 Author: Bram Moolenaar Date: Sun Apr 26 13:50:41 2020 +0200 patch 8.2.0641: Vim9: not expanded in :hardcopy and syn-include Problem: Vim9: not expanded in :hardcopy and "syntax include". Solution: Add the EX_EXPAND flag. Expend "syntax include". diff --git a/src/ex_cmds.h b/src/ex_cmds.h --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -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_helpt 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, diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 641, +/**/ 640, /**/ 639, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -5821,14 +5821,23 @@ compile_mult_expr(char_u *arg, int cmdid 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; - - if ((excmd_get_argt(eap->cmdidx) & EX_XFILE) - && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL) + 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 (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL) { int count = 0; char_u *start = skipwhite(line); diff --git a/src/vim9execute.c b/src/vim9execute.c --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -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); }