Thanks, Vitalije. I had rejected the 'save2' approach because I wanted to run the git commit in the background so it wouldn't add any extra time to the save. Using 'save2' doesn't preclude running the process in the background, but if I take the "naive" approach of using g.execute_shell_commands, then I'm left with the issue of defunct processes (since that function never calls the communicate method for background processes). So I was left with the choice between learning more about Popen and just using the entr utility which I was already familiar with. I chose the latter but that led to the issue of needing to use flock. I may reconsider my choice.
If I do reconsider, then your response will give me a head start on properly using the 'save' hook. On Sun, Sep 15, 2019 at 9:07 AM vitalije <[email protected]> wrote: > The essential part of the above script is just g.registerHandler('save2', > my_callback). The rest is just for making possible to deactivate handler > and to make every commit with the next natural number. While developing > your handler, it is useful to be able to deactivate it in case of an error. > Also if you change script and run it again it will register another version > of your handler. Quite often, in development, I use the same method to > un-register old version and then register the new one. > > def reactivate(tag, handler): > k = '_activation_%s_handler'%tag > # this is just to prevent collisions > # you can use whatever string as a key > old_handler = c.user_dict.pop(k, None) > if old_handler: > g.unregisterHandler(tag, old_handler) > g.registerHandler(tag, handler) > c.user_dict[k] = handler > reactivate('save2', my_callback) > > HTH Vitalije. > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/leo-editor/630dd216-994f-4a7a-805a-e1b20ed2ae34%40googlegroups.com > <https://groups.google.com/d/msgid/leo-editor/630dd216-994f-4a7a-805a-e1b20ed2ae34%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAO5X8CxTsNnpmw898nxQFUwMjusD5LLfx_f0oqOy8pH2FKnzoA%40mail.gmail.com.
