source or load an autoload script

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

source or load an autoload script

Ni Va
Hi,


I'am writing a plugin with autoload part:
myplugin\autoload\myplugin.vim


A Command mapped on a function of this autoload/myplugin.vim.



I don't know other solution that quit vim and relaunch to source my modifications.

Have you got an advice ?
Thank
Niva

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Christian Brabandt

On Do, 17 Aug 2017, Ni Va wrote:

> Hi,
>
>
> I'am writing a plugin with autoload part:
> myplugin\autoload\myplugin.vim
>
>
> A Command mapped on a function of this autoload/myplugin.vim.
>
>
>
> I don't know other solution that quit vim and relaunch to source my modifications.

I don't understand what problem you are trying to solve.


Best,
Christian
--
Es liegt in der menschlichen Natur, vernünftig zu denken und unlogisch
zu handeln.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
Le jeudi 17 août 2017 22:55:13 UTC+2, Christian Brabandt a écrit :

> On Do, 17 Aug 2017, Ni Va wrote:
>
> > Hi,
> >
> >
> > I'am writing a plugin with autoload part:
> > myplugin\autoload\myplugin.vim
> >
> >
> > A Command mapped on a function of this autoload/myplugin.vim.
> >
> >
> >
> > I don't know other solution that quit vim and relaunch to source my modifications.
>
> I don't understand what problem you are trying to solve.
>
>
> Best,
> Christian
> --
> Es liegt in der menschlichen Natur, vernünftig zu denken und unlogisch
> zu handeln.
OK. My problem is that I don't see effect when I modify a vimscript.
In the joined screen, you can see two vimscript. The right one is a 'class' instanciated in the left one. Then a simple command MK call MakeMyVim.

So, if I modify my vimscritp class and launch MK command, I don't see effect of my change as if it was not sourced.

Thank you by advance.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

Sans titre.png (50K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Nikolay Aleksandrovich Pavlov
2017-08-18 11:13 GMT+03:00 Ni Va <[hidden email]>:

> Le jeudi 17 août 2017 22:55:13 UTC+2, Christian Brabandt a écrit :
>> On Do, 17 Aug 2017, Ni Va wrote:
>>
>> > Hi,
>> >
>> >
>> > I'am writing a plugin with autoload part:
>> > myplugin\autoload\myplugin.vim
>> >
>> >
>> > A Command mapped on a function of this autoload/myplugin.vim.
>> >
>> >
>> >
>> > I don't know other solution that quit vim and relaunch to source my modifications.
>>
>> I don't understand what problem you are trying to solve.
>>
>>
>> Best,
>> Christian
>> --
>> Es liegt in der menschlichen Natur, vernünftig zu denken und unlogisch
>> zu handeln.
>
> OK. My problem is that I don't see effect when I modify a vimscript.
> In the joined screen, you can see two vimscript. The right one is a 'class' instanciated in the left one. Then a simple command MK call MakeMyVim.
>
> So, if I modify my vimscritp class and launch MK command, I don't see effect of my change as if it was not sourced.
>
> Thank you by advance.

You need to :source autoload file yourself, :unletting guard variable
before sourcing. But note that this is generally incorrect, e.g. if
you remove some function from autoload file, but forget to remove it
from the users of the file, then function will stay in memory and
users will still work, up until you restart Vim.

Thus in any case restart Vim before publishing the modified script.

>
> --
> --
> You received this message from the "vim_use" 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_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
Le vendredi 18 août 2017 10:28:30 UTC+2, ZyX a écrit :

> 2017-08-18 11:13 GMT+03:00 Ni Va <[hidden email]>:
> > Le jeudi 17 août 2017 22:55:13 UTC+2, Christian Brabandt a écrit :
> >> On Do, 17 Aug 2017, Ni Va wrote:
> >>
> >> > Hi,
> >> >
> >> >
> >> > I'am writing a plugin with autoload part:
> >> > myplugin\autoload\myplugin.vim
> >> >
> >> >
> >> > A Command mapped on a function of this autoload/myplugin.vim.
> >> >
> >> >
> >> >
> >> > I don't know other solution that quit vim and relaunch to source my modifications.
> >>
> >> I don't understand what problem you are trying to solve.
> >>
> >>
> >> Best,
> >> Christian
> >> --
> >> Es liegt in der menschlichen Natur, vernünftig zu denken und unlogisch
> >> zu handeln.
> >
> > OK. My problem is that I don't see effect when I modify a vimscript.
> > In the joined screen, you can see two vimscript. The right one is a 'class' instanciated in the left one. Then a simple command MK call MakeMyVim.
> >
> > So, if I modify my vimscritp class and launch MK command, I don't see effect of my change as if it was not sourced.
> >
> > Thank you by advance.
>
> You need to :source autoload file yourself, :unletting guard variable
> before sourcing. But note that this is generally incorrect, e.g. if
> you remove some function from autoload file, but forget to remove it
> from the users of the file, then function will stay in memory and
> users will still work, up until you restart Vim.
>
> Thus in any case restart Vim before publishing the modified script.
>
> >
> > --
> > --
> > You received this message from the "vim_use" 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_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> > For more options, visit https://groups.google.com/d/optout.
Ok that was that I did. Restarting Vim. bouuh :(    
Thank You ! :)

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Luc Hermitte
In reply to this post by Ni Va


De: "Ni Va" <[hidden email]>
> OK. My problem is that I don't see effect when I modify a vimscript.
> In the joined screen, you can see two vimscript. The right one is a
> 'class' instanciated in the left one. Then a simple command MK call
> MakeMyVim.
>
> So, if I modify my vimscritp class and launch MK command, I don't see
> effect of my change as if it was not sourced.

That seems normal. trigger#new()['setup'] cannot be updated without calling new() again.
My take on the subject: never define methods this ways. Prefer to define a s:method and bind it in the constructor/creator function with

let new_obj.method_name = function('s:method_implementation')

First it'll allow reloading. But also, it'll improve greatly debugability.

I've written more on the subject on SO: https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268

BTW, autoload plugins don't need anti-inclusion guards. It makes no sense there.

HTH,

--
Luc Hermitte

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
Le vendredi 18 août 2017 10:46:49 UTC+2, Luc Hermitte a écrit :

> De: "Ni Va" <[hidden email]>
> > OK. My problem is that I don't see effect when I modify a vimscript.
> > In the joined screen, you can see two vimscript. The right one is a
> > 'class' instanciated in the left one. Then a simple command MK call
> > MakeMyVim.
> >
> > So, if I modify my vimscritp class and launch MK command, I don't see
> > effect of my change as if it was not sourced.
>
> That seems normal. trigger#new()['setup'] cannot be updated without calling new() again.
> My take on the subject: never define methods this ways. Prefer to define a s:method and bind it in the constructor/creator function with
>
> let new_obj.method_name = function('s:method_implementation')
>
> First it'll allow reloading. But also, it'll improve greatly debugability.
>
> I've written more on the subject on SO: https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
>
> BTW, autoload plugins don't need anti-inclusion guards. It makes no sense there.
>
> HTH,
>
> --
> Luc Hermitte
With some editing basic modifications I got this :



Messages maintainer: Bram Moolenaar <[hidden email]>
Error detected while processing function makemyvim#MakeMyVim[13]..trigger#new:
line    9:
E475: Invalid argument: s:setup(...)              
line   10:
E475: Invalid argument: s:Event_FileReadable(file)
line   11:
E475: Invalid argument: s:setEventDetection(event)
line   12:
E475: Invalid argument: s:TimerHandler(timerId)  
line   13:
E475: Invalid argument: s:isTheEnd()              
line   14:
E475: Invalid argument: s:getTriggerObject()      
line   15:
E475: Invalid argument: s:setTriggerObject(object)
line   16:
E475: Invalid argument: s:start()                
Error detected while processing function makemyvim#MakeMyVim:
line   14:
E718: Funcref required
line   15:
E718: Funcref required
line   16:
E15: Invalid expression: x.isTheEnd()
line   25:
E906: not an open channel

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

vimscripts.7z (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
In reply to this post by Luc Hermitte
Le vendredi 18 août 2017 10:46:49 UTC+2, Luc Hermitte a écrit :

> De: "Ni Va" <[hidden email]>
> > OK. My problem is that I don't see effect when I modify a vimscript.
> > In the joined screen, you can see two vimscript. The right one is a
> > 'class' instanciated in the left one. Then a simple command MK call
> > MakeMyVim.
> >
> > So, if I modify my vimscritp class and launch MK command, I don't see
> > effect of my change as if it was not sourced.
>
> That seems normal. trigger#new()['setup'] cannot be updated without calling new() again.
> My take on the subject: never define methods this ways. Prefer to define a s:method and bind it in the constructor/creator function with
>
> let new_obj.method_name = function('s:method_implementation')
>
> First it'll allow reloading. But also, it'll improve greatly debugability.
>
> I've written more on the subject on SO: https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
>
> BTW, autoload plugins don't need anti-inclusion guards. It makes no sense there.
>
> HTH,
>
> --
> Luc Hermitte
--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

Sans titre.png (81K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
In reply to this post by Luc Hermitte
Le vendredi 18 août 2017 10:46:49 UTC+2, Luc Hermitte a écrit :

> De: "Ni Va" <[hidden email]>
> > OK. My problem is that I don't see effect when I modify a vimscript.
> > In the joined screen, you can see two vimscript. The right one is a
> > 'class' instanciated in the left one. Then a simple command MK call
> > MakeMyVim.
> >
> > So, if I modify my vimscritp class and launch MK command, I don't see
> > effect of my change as if it was not sourced.
>
> That seems normal. trigger#new()['setup'] cannot be updated without calling new() again.
> My take on the subject: never define methods this ways. Prefer to define a s:method and bind it in the constructor/creator function with
>
> let new_obj.method_name = function('s:method_implementation')
>
> First it'll allow reloading. But also, it'll improve greatly debugability.
>
> I've written more on the subject on SO: https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
>
> BTW, autoload plugins don't need anti-inclusion guards. It makes no sense there.
>
> HTH,
>
> --
> Luc Hermitte
Got a message of two many argument about a function declared with One arg.
Don't understand.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

Sans titre.png (115K) Download Attachment
Sans titre2.png (37K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
In reply to this post by Luc Hermitte
Le vendredi 18 août 2017 10:46:49 UTC+2, Luc Hermitte a écrit :

> De: "Ni Va" <[hidden email]>
> > OK. My problem is that I don't see effect when I modify a vimscript.
> > In the joined screen, you can see two vimscript. The right one is a
> > 'class' instanciated in the left one. Then a simple command MK call
> > MakeMyVim.
> >
> > So, if I modify my vimscritp class and launch MK command, I don't see
> > effect of my change as if it was not sourced.
>
> That seems normal. trigger#new()['setup'] cannot be updated without calling new() again.
> My take on the subject: never define methods this ways. Prefer to define a s:method and bind it in the constructor/creator function with
>
> let new_obj.method_name = function('s:method_implementation')
>
> First it'll allow reloading. But also, it'll improve greatly debugability.
>
> I've written more on the subject on SO: https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
>
> BTW, autoload plugins don't need anti-inclusion guards. It makes no sense there.
>
> HTH,
>
> --
> Luc Hermitte
Ok Luc, Vimscript modified as described.

Than when I launch :w! | so% | MK, nothing is took on the fly.

I modify maxTimes allowed to attempt some jobs in my script but passing it from 20 to 15 let show 20 after launch.

An idea ?

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

Sans titre.png (156K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Luc Hermitte
Hi,

> > I've written more on the subject on SO:
> > https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
> >
> Ok Luc, Vimscript modified as described.
>
> Than when I launch :w! | so% | MK, nothing is took on the fly.
>
> I modify maxTimes allowed to attempt some jobs in my script but
> passing it from 20 to 15 let show 20 after launch.

A few:
- you've forgotten the `dict` attribute
- if your version of vim is to old, `function('s:funcname')` won't work.
- you still have a useless and undesired anti-reinclusion guard in your autoload plugin

BTW, if you wish to add methods to an object that already exists, they'll have to be injected on a reference of the object as you won't execute whatever#new() on an object that already exists. That's the reason behind by lh#object#inject_method(): https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/object.vim#L96

Here is a patched, and untested, version of your file.


--
Luc Hermitte

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

trigger2.vim (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Luc Hermitte
In reply to this post by Ni Va
Hi,

> > I've written more on the subject on SO:
> > https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
> >
> Ok Luc, Vimscript modified as described.
>
> Than when I launch :w! | so% | MK, nothing is took on the fly.
>
> I modify maxTimes allowed to attempt some jobs in my script but
> passing it from 20 to 15 let show 20 after launch.

A few:
- you've forgotten the `dict` attribute
- if your version of vim is to old, `function('s:funcname')` won't work.
- you still have a useless and undesired anti-reinclusion guard in your autoload plugin

BTW, if you wish to add methods to an object that already exists, they'll have to be injected on a reference of the object as you won't execute whatever#new() on an object that already exists. That's the reason behind by lh#object#inject_method(): https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/object.vim#L96

Here is a patched, and untested, version of your file.


--
Luc Hermitte

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

trigger2.vim (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: source or load an autoload script

Ni Va
Le vendredi 18 août 2017 18:54:23 UTC+2, Luc Hermitte a écrit :

> Hi,
>
> > > I've written more on the subject on SO:
> > > https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
> > >
> > Ok Luc, Vimscript modified as described.
> >
> > Than when I launch :w! | so% | MK, nothing is took on the fly.
> >
> > I modify maxTimes allowed to attempt some jobs in my script but
> > passing it from 20 to 15 let show 20 after launch.
>
> A few:
> - you've forgotten the `dict` attribute
> - if your version of vim is to old, `function('s:funcname')` won't work.
> - you still have a useless and undesired anti-reinclusion guard in your autoload plugin
>
> BTW, if you wish to add methods to an object that already exists, they'll have to be injected on a reference of the object as you won't execute whatever#new() on an object that already exists. That's the reason behind by lh#object#inject_method(): https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/object.vim#L96
>
> Here is a patched, and untested, version of your file.
>
>
> --
> Luc Hermitte
Thank you Sir !
Lazy guy may i am.
Niva

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.