To: vim_dev@googlegroups.com Subject: Patch 8.2.0641 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0641 Problem: Vim9: `=expr` not expanded in :hardcopy and "syntax include". Solution: Add the EX_EXPAND flag. Expend "syntax include". Files: src/ex_cmds.h, src/vim9compile.c, src/vim9execute.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.0640/src/ex_cmds.h 2020-04-18 17:45:34.702165051 +0200 --- src/ex_cmds.h 2020-04-25 20:41:53.011519525 +0200 *************** *** 53,58 **** --- 53,60 ---- #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,659 **** 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, ADDR_LINES), EXCMD(CMD_highlight, "highlight", ex_highlight, EX_BANG|EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN, --- 655,661 ---- EX_NEEDARG|EX_FILES|EX_TRLBAR|EX_CMDWIN, ADDR_NONE), EXCMD(CMD_hardcopy, "hardcopy", ex_hardcopy, ! 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, *** ../vim-8.2.0640/src/vim9compile.c 2020-04-25 20:02:36.001096124 +0200 --- src/vim9compile.c 2020-04-25 23:39:17.087862658 +0200 *************** *** 5821,5834 **** static char_u * compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx) { ! char_u *p; if (cctx->ctx_skip == TRUE) goto theend; ! if ((excmd_get_argt(eap->cmdidx) & EX_XFILE) ! && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL) { int count = 0; char_u *start = skipwhite(line); --- 5821,5843 ---- static char_u * compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx) { ! 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 (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL) { int count = 0; char_u *start = skipwhite(line); *** ../vim-8.2.0640/src/vim9execute.c 2020-04-25 20:02:36.001096124 +0200 --- src/vim9execute.c 2020-04-25 23:42:31.871116862 +0200 *************** *** 645,650 **** --- 645,651 ---- { // execute Ex command line case ISN_EXEC: + SOURCING_LNUM = iptr->isn_lnum; do_cmdline_cmd(iptr->isn_arg.string); break; *************** *** 682,687 **** --- 683,689 ---- } } + SOURCING_LNUM = iptr->isn_lnum; do_cmdline_cmd(cmd); vim_free(cmd); } *** ../vim-8.2.0640/src/testdir/test_vim9_cmd.vim 2020-04-25 20:02:36.001096124 +0200 --- src/testdir/test_vim9_cmd.vim 2020-04-25 23:50:54.789476168 +0200 *************** *** 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,23 **** --- 20,48 ---- 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 *** ../vim-8.2.0640/src/version.c 2020-04-25 20:02:36.001096124 +0200 --- src/version.c 2020-04-25 23:52:01.709276524 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 641, /**/ -- hundred-and-one symptoms of being an internet addict: 19. All of your friends have an @ in their names. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///