]> granicus.if.org Git - vim/commitdiff
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful v8.2.4136
authorBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 16:26:24 +0000 (16:26 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 16:26:24 +0000 (16:26 +0000)
Problem:    Vim9: the "autoload" argument of ":vim9script" is not useful.
Solution:   Remove the argument. (closes #9555)

runtime/doc/repeat.txt
runtime/doc/vim9.txt
src/errors.h
src/testdir/test_vim9_import.vim
src/version.c
src/vim9script.c

index 067234a018d8b870b601178a2cb60ca1b6756cd9..9a82ba463da08d8ff9337a6c1e1942fa5f4b6e4a 100644 (file)
@@ -365,12 +365,11 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
                        Vim version, or update Vim to a newer version.  See
                        |vimscript-version| for what changed between versions.
 
-:vim9s[cript] [noclear] [autoload]                     *:vim9s* *:vim9script*
+:vim9s[cript] [noclear]                                *:vim9s* *:vim9script*
                        Marks a script file as containing |Vim9-script|
                        commands.  Also see |vim9-namespace|.
                        Must be the first command in the file.
                        For [noclear] see |vim9-reload|.
-                       For [autoload] see |vim9-autoload|.
                        Without the |+eval| feature this changes the syntax
                        for some commands.
                        See |:vim9cmd| for executing one command with Vim9
@@ -378,8 +377,8 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
 
                                                *:scr* *:scriptnames*
 :scr[iptnames]         List all sourced script names, in the order they were
-                       first sourced.  The number is used for the script ID
-                       |<SID>|.
+                       first encountered.  The number is used for the script
+                       ID |<SID>|.
                        For a script that was used with `import autoload` but
                        was not actually sourced yet an "A" is shown after the
                        script ID.
index 94a505773f21a000f9fd96694d5739873c5b4471..bbdc2bdf40ae87b40bf9a393e7222ac45c2f438d 100644 (file)
@@ -1,4 +1,4 @@
-*vim9.txt*     For Vim version 8.2.  Last change: 2022 Jan 15
+*vim9.txt*     For Vim version 8.2.  Last change: 2022 Jan 18
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1523,17 +1523,18 @@ actually needed.  Using the autoload mechanism is recommended:
    directory.
 
 2. In the autoload script put the bulk of the code. >
-       vim9script autoload
+       vim9script
        export def Stuff(arg: string)
          ...
 
 <   This goes in .../autoload/for/search.vim.
 
-   Adding "autoload" to `:vim9script` has the effect that "for#search#" will
-   be prefixed to every exported item.  The prefix is obtained from the file
-   name, as you would to manually in a legacy autoload script.  Thus the
-   exported function can be found with "for#search#Stuff", but you would
-   normally use `import autoload` and not need to specify the prefix.
+   Putting the "search.vim" script under the "/autoload/for/" directory has
+   the effect that "for#search#" will be prefixed to every exported item.  The
+   prefix is obtained from the file name, as you would to manually in a
+   legacy autoload script.  Thus the exported function can be found with
+   "for#search#Stuff", but you would normally use `import autoload` and not
+   use the prefix.
 
    You can split up the functionality and import other scripts from the
    autoload script as you like.  This way you can share code between plugins.
index e576f810c631eaa014afc14033370ad7e382c233..0d11416a1da735c26da5cb1a42edd84b8b8c42f3 100644 (file)
@@ -3208,8 +3208,7 @@ EXTERN char e_cannot_import_dot_vim_without_using_as[]
        INIT(= N_("E1261: Cannot import .vim without using \"as\""));
 EXTERN char e_cannot_import_same_script_twice_str[]
        INIT(= N_("E1262: Cannot import the same script twice: %s"));
-EXTERN char e_using_autoload_in_script_not_under_autoload_directory[]
-       INIT(= N_("E1263: Using autoload in a script not under an autoload directory"));
+// E1263 unused
 EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[]
        INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s"));
 EXTERN char e_cannot_use_partial_here[]
index 6abe478701fd7c25d94aa14afacbeea81d7eba43..3c55f431220f91478eab705e74c487a72d471350 100644 (file)
@@ -1196,9 +1196,9 @@ def Test_vim9script_autoload()
   var save_rtp = &rtp
   exe 'set rtp^=' .. getcwd() .. '/Xdir'
 
-  # when using "vim9script autoload" prefix is not needed
+  # when the path has "/autoload/" prefix is not needed
   var lines =<< trim END
-     vim9script autoload
+     vim9script
      g:prefixed_loaded += 1
 
      export def Gettest(): string
@@ -1262,7 +1262,7 @@ def Test_vim9script_autoload_call()
   exe 'set rtp^=' .. getcwd() .. '/Xdir'
 
   var lines =<< trim END
-     vim9script autoload
+     vim9script
 
      export def RetArg(arg: string): string
        return arg
@@ -1300,7 +1300,7 @@ def Test_import_autoload_postponed()
   exe 'set rtp^=' .. getcwd() .. '/Xdir'
 
   var lines =<< trim END
-      vim9script autoload
+      vim9script
 
       g:loaded_postponed = 'true'
       export var variable = 'bla'
@@ -1337,7 +1337,7 @@ def Test_import_autoload_override()
   test_override('autoload', 1)
 
   var lines =<< trim END
-      vim9script autoload
+      vim9script
 
       g:loaded_override = 'true'
       export var variable = 'bla'
@@ -1372,7 +1372,7 @@ def Test_autoload_mapping()
   exe 'set rtp^=' .. getcwd() .. '/Xdir'
 
   var lines =<< trim END
-      vim9script autoload
+      vim9script
 
       g:toggle_loaded = 'yes'
 
@@ -1423,7 +1423,13 @@ def Test_vim9script_autoload_fails()
       vim9script autoload
       var n = 0
   END
-  CheckScriptFailure(lines, 'E1263:')
+  CheckScriptFailure(lines, 'E475: Invalid argument: autoload')
+
+  lines =<< trim END
+      vim9script noclear noclear
+      var n = 0
+  END
+  CheckScriptFailure(lines, 'E983: Duplicate argument: noclear')
 enddef
 
 def Test_import_autoload_fails()
@@ -1516,7 +1522,7 @@ enddef
 " test using a autoloaded file that is case sensitive
 def Test_vim9_autoload_case_sensitive()
   var lines =<< trim END
-     vim9script autoload
+     vim9script
      export def CaseSensitive(): string
        return 'done'
      enddef
index 679d25889b4b06890268bc89c4edcdef204c826d..b2e7429d0008a4c362059aa6a252f23ca00e5cc2 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4136,
 /**/
     4135,
 /**/
index b35634786804b787c656d1e5497f941f24d1d71b..2f7f732ac42d11bfa4354fbe1391d9efef38be4b 100644 (file)
@@ -69,7 +69,6 @@ ex_vim9script(exarg_T *eap UNUSED)
     int                    sid = current_sctx.sc_sid;
     scriptitem_T    *si;
     int                    found_noclear = FALSE;
-    int                    found_autoload = FALSE;
     char_u         *p;
 
     if (!getline_equal(eap->getline, eap->cookie, getsourceline))
@@ -96,20 +95,6 @@ ex_vim9script(exarg_T *eap UNUSED)
            }
            found_noclear = TRUE;
        }
-       else if (STRNCMP(p, "autoload", 8) == 0 && IS_WHITE_OR_NUL(p[8]))
-       {
-           if (found_autoload)
-           {
-               semsg(_(e_duplicate_argument_str), p);
-               return;
-           }
-           found_autoload = TRUE;
-           if (script_name_after_autoload(si) == NULL)
-           {
-               emsg(_(e_using_autoload_in_script_not_under_autoload_directory));
-               return;
-           }
-       }
        else
        {
            semsg(_(e_invalid_argument_str), eap->arg);