Patch 8.2.2531
Problem: Vim9: the :k command is obscure.
Solution: Disallow using :k, can use :mark instead. (closes #7874)
Files: runtime/doc/vim9.txt, src/ex_docmd.c, src/vim9script.c,
src/vim9compile.c, src/ex_cmds.h, src/testdir/test_vim9_script.vim
*** ../vim-8.2.2530/runtime/doc/vim9.txt 2021-02-17 21:56:59.905196323
+0100
--- runtime/doc/vim9.txt 2021-02-19 21:12:10.916748454 +0100
***************
*** 96,103 ****
def CallMe(count: number, message: string): bool
- Call functions without `:call`: >
writefile(['done'], 'file.txt')
! - You cannot use `:xit`, `:t`, `:append`, `:change`, `:insert` or curly-braces
! names.
- A range before a command must be prefixed with a colon: >
:%s/this/that
- Unless mentioned specifically, the highest |scriptversion| is used.
--- 96,103 ----
def CallMe(count: number, message: string): bool
- Call functions without `:call`: >
writefile(['done'], 'file.txt')
! - You cannot use `:xit`, `:t`, `:k`, `:append`, `:change`, `:insert` or
! curly-braces names.
- A range before a command must be prefixed with a colon: >
:%s/this/that
- Unless mentioned specifically, the highest |scriptversion| is used.
***************
*** 562,572 ****
{'456': 'with', '123': 'without'}
! No :xit, :t, :append, :change or :insert ~
These commands are too easily confused with local variable names.
Instead of `:x` or `:xit` you can use `:exit`.
Instead of `:t` you can use `:copy`.
Comparators ~
--- 562,573 ----
{'456': 'with', '123': 'without'}
! No :xit, :t, :k, :append, :change or :insert ~
These commands are too easily confused with local variable names.
Instead of `:x` or `:xit` you can use `:exit`.
Instead of `:t` you can use `:copy`.
+ Instead of `:k` you can use `:mark`.
Comparators ~
*** ../vim-8.2.2530/src/ex_docmd.c 2021-02-17 21:56:59.909196307 +0100
--- src/ex_docmd.c 2021-02-19 21:26:12.910931055 +0100
***************
*** 3461,3467 ****
/*
* Isolate the command and search for it in the command table.
* Exceptions:
! * - the 'k' command can directly be followed by any character.
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
* but :sre[wind] is another command, as are :scr[iptnames],
* :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
--- 3461,3468 ----
/*
* Isolate the command and search for it in the command table.
* Exceptions:
! * - The 'k' command can directly be followed by any character.
! * But it is not used in Vim9 script.
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
* but :sre[wind] is another command, as are :scr[iptnames],
* :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
***************
*** 8056,8061 ****
--- 8057,8066 ----
{
pos_T pos;
+ #ifdef FEAT_EVAL
+ if (not_in_vim9(eap) == FAIL)
+ return;
+ #endif
if (*eap->arg == NUL) // No argument?
emsg(_(e_argreq));
else if (eap->arg[1] != NUL) // more than one character?
*** ../vim-8.2.2530/src/vim9script.c 2021-02-14 13:29:57.617276973 +0100
--- src/vim9script.c 2021-02-19 21:20:44.563633250 +0100
***************
*** 95,100 ****
--- 95,101 ----
case CMD_append:
case CMD_change:
case CMD_insert:
+ case CMD_k:
case CMD_t:
case CMD_xit:
semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd);
*** ../vim-8.2.2530/src/vim9compile.c 2021-02-17 14:52:10.539374448 +0100
--- src/vim9compile.c 2021-02-19 21:25:08.911065835 +0100
***************
*** 8520,8525 ****
--- 8520,8526 ----
case CMD_append:
case CMD_change:
case CMD_insert:
+ case CMD_k:
case CMD_t:
case CMD_xit:
not_in_vim9(&ea);
*** ../vim-8.2.2530/src/ex_cmds.h 2021-02-14 12:57:32.552655477 +0100
--- src/ex_cmds.h 2021-02-19 21:22:31.423400902 +0100
***************
*** 741,747 ****
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_k, "k", ex_mark,
! EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_LINES),
EXCMD(CMD_keepmarks, "keepmarks", ex_wrongmodifier,
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
--- 741,747 ----
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_k, "k", ex_mark,
!
EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK,
ADDR_LINES),
EXCMD(CMD_keepmarks, "keepmarks", ex_wrongmodifier,
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
*** ../vim-8.2.2530/src/testdir/test_vim9_script.vim 2021-02-17
21:56:59.909196307 +0100
--- src/testdir/test_vim9_script.vim 2021-02-19 21:24:02.503205010 +0100
***************
*** 3491,3496 ****
--- 3491,3521 ----
unlet g:guard
enddef
+ def Test_unsupported_commands()
+ var lines =<< trim END
+ ka
+ END
+ CheckDefAndScriptFailure(lines, 'E1100:')
+
+ lines =<< trim END
+ t
+ END
+ CheckDefFailure(lines, 'E1100:')
+ CheckScriptFailure(['vim9script'] + lines, 'E1100:')
+
+ lines =<< trim END
+ x
+ END
+ CheckDefFailure(lines, 'E1100:')
+ CheckScriptFailure(['vim9script'] + lines, 'E1100:')
+
+ lines =<< trim END
+ xit
+ END
+ CheckDefFailure(lines, 'E1100:')
+ CheckScriptFailure(['vim9script'] + lines, 'E1100:')
+ enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
*** ../vim-8.2.2530/src/version.c 2021-02-19 19:13:13.087904339 +0100
--- src/version.c 2021-02-19 21:42:30.080836148 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2531,
/**/
--
TALL KNIGHT: Firstly. You must get us another shrubbery!
OTHER KNIGHTS: More shrubberies! More shrubberies for the ex-Knights of Ni!
ARTHUR: Not another shrubbery -
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202102192044.11JKiBDM2807514%40masaka.moolenaar.net.