Re: Patch 8.2.4050

2022-01-10 Fir de Conversatie Maxim Kim
Oops, I take it back -- it doesn't work :)

вторник, 11 января 2022 г. в 09:31:54 UTC+3, Maxim Kim: 

> Following:
>
> import autoload 'comment.vim'
> nnoremap   gc comment.Toggle()
> xnoremap   gc comment.Toggle()
> nnoremap   gcc comment.Toggle() .. '_'
>
> Now works (as of 8.2.4058)
> понедельник, 10 января 2022 г. в 15:17:40 UTC+3, Bram Moolenaar: 
>
>>
>> Maxim Kim wrote: 
>>
>> > I have tried new way of autoload and for me it didn't work (windows 
>> > 8.2.4050) 
>> > 
>> > I have autoload/comment.vim: 
>> > 
>> > vim9script autoload 
>> > 
>> > # Toggle comments 
>> > # Usage: 
>> > # 1. Save in ~/.vim/autoload/comment.vim 
>> > # 2. Add following mappings to vimrc: 
>> > # import autoload 'comment.vim' 
>> > # nnoremap   gc comment.Toggle() 
>> > # xnoremap   gc comment.Toggle() 
>> > # nnoremap   gcc comment.Toggle() .. '_' 
>> > export def Toggle(...args: list): string 
>> > ... 
>> > 
>> > And in my ~/vimfiles/vimrc: 
>> > 
>> > import autoload 'comment.vim' 
>> > nnoremap   gc comment.Toggle() 
>> > xnoremap   gc comment.Toggle() 
>> > nnoremap   gcc comment.Toggle() .. '_' 
>> > # nnoremap   gc comment#toggle() 
>> > # xnoremap   gc comment#toggle() 
>> > # nnoremap   gcc comment#toggle() .. '_' 
>> > 
>> > After pressing gcc I get error: 
>> > 
>> > E121: Undefined variable: comment 
>>
>> This isn't fully implemented yet. It turns out it's more complicated. 
>>
>> Thanks for the example, I'll try it out after some more changes. 
>>
>> -- 
>> GALAHAD: Camelot ... 
>> LAUNCELOT: Camelot ... 
>> GAWAIN: It's only a model. 
>> "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD 
>>
>> /// Bram Moolenaar -- br...@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 /// 
>>
>

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/150ae53a-06c2-41ad-9e1c-2f45a62a3452n%40googlegroups.com.


Re: Patch 8.2.4050

2022-01-10 Fir de Conversatie Maxim Kim
Following:

import autoload 'comment.vim'
nnoremap   gc comment.Toggle()
xnoremap   gc comment.Toggle()
nnoremap   gcc comment.Toggle() .. '_'

Now works (as of 8.2.4058)
понедельник, 10 января 2022 г. в 15:17:40 UTC+3, Bram Moolenaar: 

>
> Maxim Kim wrote:
>
> > I have tried new way of autoload and for me it didn't work (windows 
> > 8.2.4050)
> > 
> > I have autoload/comment.vim:
> > 
> > vim9script autoload
> > 
> > # Toggle comments
> > # Usage:
> > # 1. Save in ~/.vim/autoload/comment.vim
> > # 2. Add following mappings to vimrc:
> > # import autoload 'comment.vim'
> > # nnoremap   gc comment.Toggle()
> > # xnoremap   gc comment.Toggle()
> > # nnoremap   gcc comment.Toggle() .. '_'
> > export def Toggle(...args: list): string
> > ...
> > 
> > And in my ~/vimfiles/vimrc:
> > 
> > import autoload 'comment.vim'
> > nnoremap   gc comment.Toggle()
> > xnoremap   gc comment.Toggle()
> > nnoremap   gcc comment.Toggle() .. '_'
> > # nnoremap   gc comment#toggle()
> > # xnoremap   gc comment#toggle()
> > # nnoremap   gcc comment#toggle() .. '_'
> > 
> > After pressing gcc I get error:
> > 
> > E121: Undefined variable: comment
>
> This isn't fully implemented yet. It turns out it's more complicated.
>
> Thanks for the example, I'll try it out after some more changes.
>
> -- 
> GALAHAD: Camelot ...
> LAUNCELOT: Camelot ...
> GAWAIN: It's only a model.
> "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
>
> /// Bram Moolenaar -- br...@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 ///
>

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/19140862-7752-4965-9147-b16e1c4a96adn%40googlegroups.com.


Re: Patch 8.2.4050

2022-01-10 Fir de Conversatie Bram Moolenaar


Maxim Kim wrote:

> I have tried new way of autoload and for me it didn't work (windows 
> 8.2.4050)
> 
> I have autoload/comment.vim:
> 
> vim9script autoload
> 
> # Toggle comments
> # Usage:
> #   1. Save in ~/.vim/autoload/comment.vim
> #   2. Add following mappings to vimrc:
> #  import autoload 'comment.vim'
> #  nnoremap   gc comment.Toggle()
> #  xnoremap   gc comment.Toggle()
> #  nnoremap   gcc comment.Toggle() .. '_'
> export def Toggle(...args: list): string
> ...
> 
> And in my ~/vimfiles/vimrc:
> 
> import autoload 'comment.vim'
> nnoremap   gc comment.Toggle()
> xnoremap   gc comment.Toggle()
> nnoremap   gcc comment.Toggle() .. '_'
> # nnoremap   gc comment#toggle()
> # xnoremap   gc comment#toggle()
> # nnoremap   gcc comment#toggle() .. '_'
> 
> After pressing gcc I get error:
> 
> E121: Undefined variable: comment

This isn't fully implemented yet.  It turns out it's more complicated.

Thanks for the example, I'll try it out after some more changes.

-- 
GALAHAD:   Camelot ...
LAUNCELOT: Camelot ...
GAWAIN:It's only a model.
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@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///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220110121734.21E991C051B%40moolenaar.net.


Re: Patch 8.2.4050

2022-01-10 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 10-Jan-2022 08:37, Bram Moolenaar wrote:
> > Patch 8.2.4050
> > Problem:Vim9: need to prefix every item in an autoload script.
> > Solution:   First step in supporting "vim9script autoload" and "import
> >  autoload".
> > Files:  runtime/doc/repeat.txt, runtime/doc/vim9.txt, src/structs.h,
> >  src/errors.h, src/vim9script.c, src/scriptfile.c,
> >  src/proto/scriptfile.pro, src/userfunc.c, src/eval.c,
> >  src/evalvars.c, src/vim9compile.c, src/proto/vim9compile.pro=
> ,
> >  src/vim9expr.c, src/testdir/test_vim9_script.vim
> >
> >
> >
> After this patch, mingw64 (gcc 11.2.0) comes up with this warning:
> 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
> -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD scriptfile.c -o 
> gobjnative/scriptfile.o
> scriptfile.c: In function 'get_new_scriptitem':
> scriptfile.c:309:23: warning: 'si' may be used uninitialized in this 
> function [-Wmaybe-uninitialized]
>    309 | si->sn_script_seq = current_sctx.sc> _seq;
>    | ~> ~^
> 
> 
> The attached patch tries to fix it.

Yeah, "si" can't really be NULL but the compiler doesn't know that.
Thanks for the patch.

Still more work to do on this autoload mechanism...

-- 
This sentence is not sure that it exists, but if it does, it will
certainly consider the possibility that other sentences exist.

 /// Bram Moolenaar -- b...@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///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220110121734.31C321C053F%40moolenaar.net.


Re: Patch 8.2.4050

2022-01-09 Fir de Conversatie Maxim Kim
I have tried new way of autoload and for me it didn't work (windows 
8.2.4050)

I have autoload/comment.vim:

vim9script autoload

# Toggle comments
# Usage:
#   1. Save in ~/.vim/autoload/comment.vim
#   2. Add following mappings to vimrc:
#  import autoload 'comment.vim'
#  nnoremap   gc comment.Toggle()
#  xnoremap   gc comment.Toggle()
#  nnoremap   gcc comment.Toggle() .. '_'
export def Toggle(...args: list): string
...

And in my ~/vimfiles/vimrc:

import autoload 'comment.vim'
nnoremap   gc comment.Toggle()
xnoremap   gc comment.Toggle()
nnoremap   gcc comment.Toggle() .. '_'
# nnoremap   gc comment#toggle()
# xnoremap   gc comment#toggle()
# nnoremap   gcc comment#toggle() .. '_'

After pressing gcc I get error:

E121: Undefined variable: comment

[image: 2022-01-10_10-17-06.png]

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/d211cce6-38c2-49fa-8458-2f7b2a513c35n%40googlegroups.com.


Re: Patch 8.2.4050

2022-01-09 Fir de Conversatie John Marriott


On 10-Jan-2022 08:37, Bram Moolenaar wrote:

Patch 8.2.4050
Problem:Vim9: need to prefix every item in an autoload script.
Solution:   First step in supporting "vim9script autoload" and "import
 autoload".
Files:  runtime/doc/repeat.txt, runtime/doc/vim9.txt, src/structs.h,
 src/errors.h, src/vim9script.c, src/scriptfile.c,
 src/proto/scriptfile.pro, src/userfunc.c, src/eval.c,
 src/evalvars.c, src/vim9compile.c, src/proto/vim9compile.pro,
 src/vim9expr.c, src/testdir/test_vim9_script.vim




After this patch, mingw64 (gcc 11.2.0) comes up with this warning:

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD scriptfile.c -o 
gobjnative/scriptfile.o

scriptfile.c: In function 'get_new_scriptitem':
scriptfile.c:309:23: warning: 'si' may be used uninitialized in this 
function [-Wmaybe-uninitialized]

  309 | si->sn_script_seq = current_sctx.sc_seq;
  | ~~^


The attached patch tries to fix it.

Cheers
John

--
--
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/f70329f7-b2da-5b83-c382-2a583ef5d25c%40internode.on.net.
--- scriptfile.c.orig   2022-01-10 11:43:15.993375400 +1100
+++ scriptfile.c2022-01-10 12:26:48.817073500 +1100
@@ -274,7 +274,7 @@
 {
 static scid_T   last_current_SID = 0;
 intsid = ++last_current_SID;
-scriptitem_T*si;
+scriptitem_T*si = NULL;
 
 if (ga_grow(_items, (int)(sid - script_items.ga_len)) == FAIL)
 {
@@ -305,8 +305,11 @@
 # endif
 }
 
-// Used to check script variable index is still valid.
-si->sn_script_seq = current_sctx.sc_seq;
+if (si != NULL)
+{
+   // Used to check script variable index is still valid.
+   si->sn_script_seq = current_sctx.sc_seq;
+}
 
 return sid;
 }


Patch 8.2.4050

2022-01-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.4050
Problem:Vim9: need to prefix every item in an autoload script.
Solution:   First step in supporting "vim9script autoload" and "import
autoload".
Files:  runtime/doc/repeat.txt, runtime/doc/vim9.txt, src/structs.h,
src/errors.h, src/vim9script.c, src/scriptfile.c,
src/proto/scriptfile.pro, src/userfunc.c, src/eval.c,
src/evalvars.c, src/vim9compile.c, src/proto/vim9compile.pro,
src/vim9expr.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.4049/runtime/doc/repeat.txt  2021-02-14 11:57:32.552655477 
+
--- runtime/doc/repeat.txt  2022-01-09 14:53:57.822209348 +
***
*** 354,369 
Vim version, or update Vim to a newer version.  See
|vimscript-version| for what changed between versions.
  
! :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|.
Without the |+eval| feature this changes the syntax
for some commands.
See |:vim9cmd| for executing one command with Vim9
syntax and semantics.
!
*:scr* *:scriptnames*
  :scr[iptnames]List all sourced script names, in the order 
they were
first sourced.  The number is used for the script ID
--- 365,381 
Vim version, or update Vim to a newer version.  See
|vimscript-version| for what changed between versions.
  
! :vim9s[cript] [noclear] [autoload]*: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
syntax and semantics.
! 
*:scr* *:scriptnames*
  :scr[iptnames]List all sourced script names, in the order 
they were
first sourced.  The number is used for the script ID
*** ../vim-8.2.4049/runtime/doc/vim9.txt2022-01-06 21:10:24.465027868 
+
--- runtime/doc/vim9.txt2022-01-09 15:09:38.686342752 +
***
*** 1484,1520 
  
  
  Import in an autoload script ~
! 
  For optimal startup speed, loading scripts should be postponed until they are
! actually needed.  A recommended mechanism:
  
  1. In the plugin define user commands, functions and/or mappings that refer to
!an autoload script. >
!   command -nargs=1 SearchForStuff searchfor#Stuff()
  
  <   This goes in .../plugin/anyname.vim.  "anyname.vim" can be freely chosen.
  
! 2. In the autoload script do the actual work.  You can import items from
!other files to split up functionality in appropriate pieces. >
!   vim9script
!   import "../import/someother.vim" as other
!   def searchfor#Stuff(arg: string)
! var filtered = other.FilterFunc(arg)
  ...
- <   This goes in .../autoload/searchfor.vim.  "searchfor" in the file name
-must be exactly the same as the prefix for the function name, that is how
-Vim finds the file.
  
! 3. Other functionality, possibly shared between plugins, contains the exported
!items and any private items. >
!   vim9script
!   var localVar = 'local'
!   export def FilterFunc(arg: string): string
!  ...
! <   This goes in .../import/someother.vim.
  
  When compiling a `:def` function and a function in an autoload script is
  encountered, the script is not loaded until the `:def` function is called.
  
  
  Import in legacy Vim script ~
--- 1501,1543 
  
  
  Import in an autoload script ~
!   *vim9-autoload*
  For optimal startup speed, loading scripts should be postponed until they are
! actually needed.  Using the autoload mechanism is recommended:
  
  1. In the plugin define user commands, functions and/or mappings that refer to
!items imported from an autoload script. >
!   import autoload 'for/search.vim'
!   command -nargs=1 SearchForStuff search.Stuff()
  
  <   This goes in .../plugin/anyname.vim.  "anyname.vim" can be freely chosen.
+The &q