summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-26 13:50:41 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-26 13:50:41 +0200
commit6378c4fef37df05c99e8a43616063b4ddb692876 (patch)
treeec861e06b203e764b5fad2cb92c38f30b66f919e
parentcfe435d7feacf123ac060747b885f7c4328062ea (diff)
patch 8.2.0641: Vim9: not expanded in :hardcopy and syn-includev8.2.0641
Problem: Vim9: not expanded in :hardcopy and "syntax include". Solution: Add the EX_EXPAND flag. Expend "syntax include".
-rw-r--r--src/ex_cmds.h4
-rw-r--r--src/testdir/test_vim9_cmd.vim25
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c15
-rw-r--r--src/vim9execute.c2
5 files changed, 44 insertions, 4 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 0c158e1bd5..25a0853bda 100644
--- 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_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,
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 7ccd1f70cc..70437b901f 100644
--- 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
index 233106b246..3829af5b3f 100644
--- 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
index 092939e08d..ccd73f77fa 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -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);
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 7172718c29..9ea7dafad3 100644
--- 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);
}