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
@@ -365,12 +365,11 @@ | ||
365 | 365 | Vim version, or update Vim to a newer version. See |
366 | 366 | |vimscript-version| for what changed between versions. |
367 | 367 | |
368 | -:vim9s[cript] [noclear] [autoload] *:vim9s* *:vim9script* | |
368 | +:vim9s[cript] [noclear] *:vim9s* *:vim9script* | |
369 | 369 | Marks a script file as containing |Vim9-script| |
370 | 370 | commands. Also see |vim9-namespace|. |
371 | 371 | Must be the first command in the file. |
372 | 372 | For [noclear] see |vim9-reload|. |
373 | - For [autoload] see |vim9-autoload|. | |
374 | 373 | Without the |+eval| feature this changes the syntax |
375 | 374 | for some commands. |
376 | 375 | See |:vim9cmd| for executing one command with Vim9 |
@@ -378,8 +377,8 @@ | ||
378 | 377 | |
379 | 378 | *:scr* *:scriptnames* |
380 | 379 | :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>|. | |
383 | 382 | For a script that was used with `import autoload` but |
384 | 383 | was not actually sourced yet an "A" is shown after the |
385 | 384 | script ID. |
@@ -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 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -1523,17 +1523,18 @@ | ||
1523 | 1523 | directory. |
1524 | 1524 | |
1525 | 1525 | 2. In the autoload script put the bulk of the code. > |
1526 | - vim9script autoload | |
1526 | + vim9script | |
1527 | 1527 | export def Stuff(arg: string) |
1528 | 1528 | ... |
1529 | 1529 | |
1530 | 1530 | < This goes in .../autoload/for/search.vim. |
1531 | 1531 | |
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. | |
1537 | 1538 | |
1538 | 1539 | You can split up the functionality and import other scripts from the |
1539 | 1540 | autoload script as you like. This way you can share code between plugins. |
@@ -3208,8 +3208,7 @@ | ||
3208 | 3208 | INIT(= N_("E1261: Cannot import .vim without using \"as\"")); |
3209 | 3209 | EXTERN char e_cannot_import_same_script_twice_str[] |
3210 | 3210 | 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 | |
3213 | 3212 | EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[] |
3214 | 3213 | INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s")); |
3215 | 3214 | EXTERN char e_cannot_use_partial_here[] |
@@ -1196,9 +1196,9 @@ | ||
1196 | 1196 | var save_rtp = &rtp |
1197 | 1197 | exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1198 | 1198 | |
1199 | - # when using "vim9script autoload" prefix is not needed | |
1199 | + # when the path has "/autoload/" prefix is not needed | |
1200 | 1200 | var lines =<< trim END |
1201 | - vim9script autoload | |
1201 | + vim9script | |
1202 | 1202 | g:prefixed_loaded += 1 |
1203 | 1203 | |
1204 | 1204 | export def Gettest(): string |
@@ -1262,7 +1262,7 @@ | ||
1262 | 1262 | exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1263 | 1263 | |
1264 | 1264 | var lines =<< trim END |
1265 | - vim9script autoload | |
1265 | + vim9script | |
1266 | 1266 | |
1267 | 1267 | export def RetArg(arg: string): string |
1268 | 1268 | return arg |
@@ -1300,7 +1300,7 @@ | ||
1300 | 1300 | exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1301 | 1301 | |
1302 | 1302 | var lines =<< trim END |
1303 | - vim9script autoload | |
1303 | + vim9script | |
1304 | 1304 | |
1305 | 1305 | g:loaded_postponed = 'true' |
1306 | 1306 | export var variable = 'bla' |
@@ -1337,7 +1337,7 @@ | ||
1337 | 1337 | test_override('autoload', 1) |
1338 | 1338 | |
1339 | 1339 | var lines =<< trim END |
1340 | - vim9script autoload | |
1340 | + vim9script | |
1341 | 1341 | |
1342 | 1342 | g:loaded_override = 'true' |
1343 | 1343 | export var variable = 'bla' |
@@ -1372,7 +1372,7 @@ | ||
1372 | 1372 | exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1373 | 1373 | |
1374 | 1374 | var lines =<< trim END |
1375 | - vim9script autoload | |
1375 | + vim9script | |
1376 | 1376 | |
1377 | 1377 | g:toggle_loaded = 'yes' |
1378 | 1378 |
@@ -1423,7 +1423,13 @@ | ||
1423 | 1423 | vim9script autoload |
1424 | 1424 | var n = 0 |
1425 | 1425 | 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') | |
1427 | 1433 | enddef |
1428 | 1434 | |
1429 | 1435 | def Test_import_autoload_fails() |
@@ -1516,7 +1522,7 @@ | ||
1516 | 1522 | " test using a autoloaded file that is case sensitive |
1517 | 1523 | def Test_vim9_autoload_case_sensitive() |
1518 | 1524 | var lines =<< trim END |
1519 | - vim9script autoload | |
1525 | + vim9script | |
1520 | 1526 | export def CaseSensitive(): string |
1521 | 1527 | return 'done' |
1522 | 1528 | enddef |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 4136, | |
755 | +/**/ | |
754 | 756 | 4135, |
755 | 757 | /**/ |
756 | 758 | 4134, |
@@ -69,7 +69,6 @@ | ||
69 | 69 | int sid = current_sctx.sc_sid; |
70 | 70 | scriptitem_T *si; |
71 | 71 | int found_noclear = FALSE; |
72 | - int found_autoload = FALSE; | |
73 | 72 | char_u *p; |
74 | 73 | |
75 | 74 | if (!getline_equal(eap->getline, eap->cookie, getsourceline)) |
@@ -96,20 +95,6 @@ | ||
96 | 95 | } |
97 | 96 | found_noclear = TRUE; |
98 | 97 | } |
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 | - } | |
113 | 98 | else |
114 | 99 | { |
115 | 100 | semsg(_(e_invalid_argument_str), eap->arg); |