0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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".
This commit is contained in:
Bram Moolenaar
2020-04-26 13:50:41 +02:00
parent cfe435d7fe
commit 6378c4fef3
5 changed files with 44 additions and 4 deletions

View File

@@ -53,6 +53,8 @@
#define EX_MODIFY 0x100000 // forbidden in non-'modifiable' buffer #define EX_MODIFY 0x100000 // forbidden in non-'modifiable' buffer
#define EX_FLAGS 0x200000 // allow flags after count in argument #define EX_FLAGS 0x200000 // allow flags after count in argument
#define EX_RESTRICT 0x400000 // forbidden in restricted mode #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_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed
#define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file #define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file
#define EX_WORD1 (EX_EXTRA | EX_NOSPC) // one extra word allowed #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, EX_NEEDARG|EX_FILES|EX_TRLBAR|EX_CMDWIN,
ADDR_NONE), ADDR_NONE),
EXCMD(CMD_hardcopy, "hardcopy", ex_hardcopy, 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), ADDR_LINES),
EXCMD(CMD_highlight, "highlight", ex_highlight, EXCMD(CMD_highlight, "highlight", ex_highlight,
EX_BANG|EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN, EX_BANG|EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN,

View File

@@ -1,5 +1,6 @@
" Test commands that are not compiled in a :def function " Test commands that are not compiled in a :def function
source check.vim
source vim9.vim source vim9.vim
def Test_edit_wildcards() def Test_edit_wildcards()
@@ -19,5 +20,29 @@ def Test_edit_wildcards()
assert_equal('XXtestxx77yy', bufname()) assert_equal('XXtestxx77yy', bufname())
enddef 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 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
641,
/**/ /**/
640, 640,
/**/ /**/

View File

@@ -5821,14 +5821,23 @@ compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
static char_u * static char_u *
compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx) 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) if (cctx->ctx_skip == TRUE)
goto theend; 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) if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
&& (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
{ {
int count = 0; int count = 0;
char_u *start = skipwhite(line); char_u *start = skipwhite(line);

View File

@@ -645,6 +645,7 @@ call_def_function(
{ {
// execute Ex command line // execute Ex command line
case ISN_EXEC: case ISN_EXEC:
SOURCING_LNUM = iptr->isn_lnum;
do_cmdline_cmd(iptr->isn_arg.string); do_cmdline_cmd(iptr->isn_arg.string);
break; break;
@@ -682,6 +683,7 @@ call_def_function(
} }
} }
SOURCING_LNUM = iptr->isn_lnum;
do_cmdline_cmd(cmd); do_cmdline_cmd(cmd);
vim_free(cmd); vim_free(cmd);
} }