• R/O
  • SSH

vim: コミット

Mirror of the Vim source from https://github.com/vim/vim


コミットメタ情報

リビジョン5b54f413d1324984011bf81fc8d90cb636c3eca5 (tree)
日時2022-01-19 01:30:05
作者Bram Moolenaar <Bram@vim....>
コミッターBram Moolenaar

ログメッセージ

patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful

Commit: https://github.com/vim/vim/commit/fd218c8a36e7ed33f7a205163690c5b7d2f31f8a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 18 16:26:24 2022 +0000

patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Problem: Vim9: the "autoload" argument of ":vim9script" is not useful.
Solution: Remove the argument. (closes https://github.com/vim/vim/issues/9555)

変更サマリ

差分

diff -r c2954285f431 -r 5b54f413d132 runtime/doc/repeat.txt
--- a/runtime/doc/repeat.txt Tue Jan 18 15:30:04 2022 +0100
+++ b/runtime/doc/repeat.txt Tue Jan 18 17:30:05 2022 +0100
@@ -365,12 +365,11 @@
365365 Vim version, or update Vim to a newer version. See
366366 |vimscript-version| for what changed between versions.
367367
368-:vim9s[cript] [noclear] [autoload] *:vim9s* *:vim9script*
368+:vim9s[cript] [noclear] *:vim9s* *:vim9script*
369369 Marks a script file as containing |Vim9-script|
370370 commands. Also see |vim9-namespace|.
371371 Must be the first command in the file.
372372 For [noclear] see |vim9-reload|.
373- For [autoload] see |vim9-autoload|.
374373 Without the |+eval| feature this changes the syntax
375374 for some commands.
376375 See |:vim9cmd| for executing one command with Vim9
@@ -378,8 +377,8 @@
378377
379378 *:scr* *:scriptnames*
380379 :scr[iptnames] List all sourced script names, in the order they were
381- first sourced. The number is used for the script ID
382- |<SID>|.
380+ first encountered. The number is used for the script
381+ ID |<SID>|.
383382 For a script that was used with `import autoload` but
384383 was not actually sourced yet an "A" is shown after the
385384 script ID.
diff -r c2954285f431 -r 5b54f413d132 runtime/doc/vim9.txt
--- a/runtime/doc/vim9.txt Tue Jan 18 15:30:04 2022 +0100
+++ b/runtime/doc/vim9.txt Tue Jan 18 17:30:05 2022 +0100
@@ -1,4 +1,4 @@
1-*vim9.txt* For Vim version 8.2. Last change: 2022 Jan 15
1+*vim9.txt* For Vim version 8.2. Last change: 2022 Jan 18
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1523,17 +1523,18 @@
15231523 directory.
15241524
15251525 2. In the autoload script put the bulk of the code. >
1526- vim9script autoload
1526+ vim9script
15271527 export def Stuff(arg: string)
15281528 ...
15291529
15301530 < This goes in .../autoload/for/search.vim.
15311531
1532- Adding "autoload" to `:vim9script` has the effect that "for#search#" will
1533- be prefixed to every exported item. The prefix is obtained from the file
1534- name, as you would to manually in a legacy autoload script. Thus the
1535- exported function can be found with "for#search#Stuff", but you would
1536- normally use `import autoload` and not need to specify the prefix.
1532+ Putting the "search.vim" script under the "/autoload/for/" directory has
1533+ the effect that "for#search#" will be prefixed to every exported item. The
1534+ prefix is obtained from the file name, as you would to manually in a
1535+ legacy autoload script. Thus the exported function can be found with
1536+ "for#search#Stuff", but you would normally use `import autoload` and not
1537+ use the prefix.
15371538
15381539 You can split up the functionality and import other scripts from the
15391540 autoload script as you like. This way you can share code between plugins.
diff -r c2954285f431 -r 5b54f413d132 src/errors.h
--- a/src/errors.h Tue Jan 18 15:30:04 2022 +0100
+++ b/src/errors.h Tue Jan 18 17:30:05 2022 +0100
@@ -3208,8 +3208,7 @@
32083208 INIT(= N_("E1261: Cannot import .vim without using \"as\""));
32093209 EXTERN char e_cannot_import_same_script_twice_str[]
32103210 INIT(= N_("E1262: Cannot import the same script twice: %s"));
3211-EXTERN char e_using_autoload_in_script_not_under_autoload_directory[]
3212- INIT(= N_("E1263: Using autoload in a script not under an autoload directory"));
3211+// E1263 unused
32133212 EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[]
32143213 INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s"));
32153214 EXTERN char e_cannot_use_partial_here[]
diff -r c2954285f431 -r 5b54f413d132 src/testdir/test_vim9_import.vim
--- a/src/testdir/test_vim9_import.vim Tue Jan 18 15:30:04 2022 +0100
+++ b/src/testdir/test_vim9_import.vim Tue Jan 18 17:30:05 2022 +0100
@@ -1196,9 +1196,9 @@
11961196 var save_rtp = &rtp
11971197 exe 'set rtp^=' .. getcwd() .. '/Xdir'
11981198
1199- # when using "vim9script autoload" prefix is not needed
1199+ # when the path has "/autoload/" prefix is not needed
12001200 var lines =<< trim END
1201- vim9script autoload
1201+ vim9script
12021202 g:prefixed_loaded += 1
12031203
12041204 export def Gettest(): string
@@ -1262,7 +1262,7 @@
12621262 exe 'set rtp^=' .. getcwd() .. '/Xdir'
12631263
12641264 var lines =<< trim END
1265- vim9script autoload
1265+ vim9script
12661266
12671267 export def RetArg(arg: string): string
12681268 return arg
@@ -1300,7 +1300,7 @@
13001300 exe 'set rtp^=' .. getcwd() .. '/Xdir'
13011301
13021302 var lines =<< trim END
1303- vim9script autoload
1303+ vim9script
13041304
13051305 g:loaded_postponed = 'true'
13061306 export var variable = 'bla'
@@ -1337,7 +1337,7 @@
13371337 test_override('autoload', 1)
13381338
13391339 var lines =<< trim END
1340- vim9script autoload
1340+ vim9script
13411341
13421342 g:loaded_override = 'true'
13431343 export var variable = 'bla'
@@ -1372,7 +1372,7 @@
13721372 exe 'set rtp^=' .. getcwd() .. '/Xdir'
13731373
13741374 var lines =<< trim END
1375- vim9script autoload
1375+ vim9script
13761376
13771377 g:toggle_loaded = 'yes'
13781378
@@ -1423,7 +1423,13 @@
14231423 vim9script autoload
14241424 var n = 0
14251425 END
1426- CheckScriptFailure(lines, 'E1263:')
1426+ CheckScriptFailure(lines, 'E475: Invalid argument: autoload')
1427+
1428+ lines =<< trim END
1429+ vim9script noclear noclear
1430+ var n = 0
1431+ END
1432+ CheckScriptFailure(lines, 'E983: Duplicate argument: noclear')
14271433 enddef
14281434
14291435 def Test_import_autoload_fails()
@@ -1516,7 +1522,7 @@
15161522 " test using a autoloaded file that is case sensitive
15171523 def Test_vim9_autoload_case_sensitive()
15181524 var lines =<< trim END
1519- vim9script autoload
1525+ vim9script
15201526 export def CaseSensitive(): string
15211527 return 'done'
15221528 enddef
diff -r c2954285f431 -r 5b54f413d132 src/version.c
--- a/src/version.c Tue Jan 18 15:30:04 2022 +0100
+++ b/src/version.c Tue Jan 18 17:30:05 2022 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 4136,
755+/**/
754756 4135,
755757 /**/
756758 4134,
diff -r c2954285f431 -r 5b54f413d132 src/vim9script.c
--- a/src/vim9script.c Tue Jan 18 15:30:04 2022 +0100
+++ b/src/vim9script.c Tue Jan 18 17:30:05 2022 +0100
@@ -69,7 +69,6 @@
6969 int sid = current_sctx.sc_sid;
7070 scriptitem_T *si;
7171 int found_noclear = FALSE;
72- int found_autoload = FALSE;
7372 char_u *p;
7473
7574 if (!getline_equal(eap->getline, eap->cookie, getsourceline))
@@ -96,20 +95,6 @@
9695 }
9796 found_noclear = TRUE;
9897 }
99- else if (STRNCMP(p, "autoload", 8) == 0 && IS_WHITE_OR_NUL(p[8]))
100- {
101- if (found_autoload)
102- {
103- semsg(_(e_duplicate_argument_str), p);
104- return;
105- }
106- found_autoload = TRUE;
107- if (script_name_after_autoload(si) == NULL)
108- {
109- emsg(_(e_using_autoload_in_script_not_under_autoload_directory));
110- return;
111- }
112- }
11398 else
11499 {
115100 semsg(_(e_invalid_argument_str), eap->arg);
旧リポジトリブラウザで表示