To: vim_dev@googlegroups.com Subject: Patch 8.2.4348 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4348 Problem: "legacy exe cmd" does not do what one would expect. Solution: Apply the "legacy" and "vim9script" command modifiers to the argument of ":execute". Files: runtime/doc/vim9.txt, src/globals.h, src/eval.c, src/ex_docmd.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.4347/runtime/doc/vim9.txt 2022-01-18 16:25:58.618309943 +0000 --- runtime/doc/vim9.txt 2022-02-11 20:31:50.442459990 +0000 *************** *** 56,69 **** rewrite old scripts, they keep working as before. You may want to use a few `:def` functions for code that needs to be fast. ! :vim9[cmd] {cmd} *:vim9* *:vim9cmd* ! Execute {cmd} using Vim9 script syntax and semantics. ! Useful when typing a command and in a legacy script or ! function. ! ! :leg[acy] {cmd} *:leg* *:legacy* ! Execute {cmd} using legacy script syntax and semantics. Only ! useful in a Vim9 script or a :def function. Note that {cmd} cannot use local variables, since it is parsed with legacy expression syntax. --- 56,69 ---- rewrite old scripts, they keep working as before. You may want to use a few `:def` functions for code that needs to be fast. ! :vim9[cmd] {cmd} *:vim9* *:vim9cmd* *E1164* ! Evaluate and execute {cmd} using Vim9 script syntax and ! semantics. Useful when typing a command and in a legacy ! script or function. ! ! :leg[acy] {cmd} *:leg* *:legacy* *E1189* *E1234* ! Evaluate and execute {cmd} using legacy script syntax and ! semantics. Only useful in a Vim9 script or a :def function. Note that {cmd} cannot use local variables, since it is parsed with legacy expression syntax. *** ../vim-8.2.4347/src/globals.h 2022-01-20 15:25:59.309844687 +0000 --- src/globals.h 2022-02-11 20:08:04.844413257 +0000 *************** *** 1156,1161 **** --- 1156,1162 ---- EXTERN int ctrl_c_interrupts INIT(= TRUE); // CTRL-C sets got_int EXTERN cmdmod_T cmdmod; // Ex command modifiers + EXTERN int sticky_cmdmod_flags INIT(= 0); // used by :execute #ifdef FEAT_EVAL EXTERN int is_export INIT(= FALSE); // :export {cmd} *** ../vim-8.2.4347/src/eval.c 2022-02-08 21:17:18.881463910 +0000 --- src/eval.c 2022-02-11 20:21:43.931494917 +0000 *************** *** 6491,6498 **** --- 6491,6506 ---- did_emsg = save_did_emsg; } else if (eap->cmdidx == CMD_execute) + { + int save_sticky_cmdmod_flags = sticky_cmdmod_flags; + + // "legacy exe cmd" and "vim9cmd exe cmd" applies to "cmd". + sticky_cmdmod_flags = cmdmod.cmod_flags + & (CMOD_LEGACY | CMOD_VIM9CMD); do_cmdline((char_u *)ga.ga_data, eap->getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE); + sticky_cmdmod_flags = save_sticky_cmdmod_flags; + } } ga_clear(&ga); *** ../vim-8.2.4347/src/ex_docmd.c 2022-02-09 12:58:16.498258787 +0000 --- src/ex_docmd.c 2022-02-11 20:22:21.831417867 +0000 *************** *** 2786,2791 **** --- 2786,2792 ---- int starts_with_colon = FALSE; CLEAR_POINTER(cmod); + cmod->cmod_flags = sticky_cmdmod_flags; // Repeat until no more command modifiers are found. for (;;) *** ../vim-8.2.4347/src/testdir/test_vim9_cmd.vim 2022-02-07 15:31:33.081531879 +0000 --- src/testdir/test_vim9_cmd.vim 2022-02-11 20:20:39.523631456 +0000 *************** *** 83,88 **** --- 83,113 ---- v9.CheckScriptSuccess(lines) enddef + def Test_cmdmod_execute() + # "legacy" applies not only to the "exe" argument but also to the commands + var lines =<< trim END + vim9script + + b:undo = 'let g:undone = 1 | let g:undtwo = 2' + legacy exe b:undo + assert_equal(1, g:undone) + assert_equal(2, g:undtwo) + END + v9.CheckScriptSuccess(lines) + + # same for "vim9cmd" modifier + lines =<< trim END + let b:undo = 'g:undone = 11 | g:undtwo = 22' + vim9cmd exe b:undo + call assert_equal(11, g:undone) + call assert_equal(22, g:undtwo) + END + v9.CheckScriptSuccess(lines) + unlet b:undo + unlet g:undone + unlet g:undtwo + enddef + def Test_edit_wildcards() var filename = 'Xtest' edit `=filename` *** ../vim-8.2.4347/src/version.c 2022-02-11 19:27:51.854714573 +0000 --- src/version.c 2022-02-11 20:05:34.324557330 +0000 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4348, /**/ -- The startling truth finally became apparent, and it was this: Numbers written on restaurant checks within the confines of restaurants do not follow the same mathematical laws as numbers written on any other pieces of paper in any other parts of the Universe. This single statement took the scientific world by storm. So many mathematical conferences got held in such good restaurants that many of the finest minds of a generation died of obesity and heart failure, and the science of mathematics was put back by years. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///