Re: Automatic git commit on save using entr

2019-09-15 Thread Chris George
On Saturday, September 14, 2019 at 1:58:57 PM UTC-7, btheado wrote: > > I'm currently using leo as my main note-taking application and I find it > very useful to have auto-saving, so I enabled the auto-save module. > > I felt a little nervous about using auto-save and decided I wanted a git > c

Re: Automatic git commit on save using entr

2019-09-15 Thread vitalije
If you want something to happen on each save regardless whether it was initiated by hitting Ctrl-s or by auto-save, the best approach would be to register a callback on 'save2' event which fires after any save. For example: from collections import Counter counter = Counter() def activate():

Re: Automatic git commit on save using entr

2019-09-15 Thread vitalije
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.

Re: p.isSelected()

2019-09-15 Thread vitalije
It seems that p.isSelected is actually never used in Leo core. Most probably it is just a remnant from ancient times. To get currently selected position you can use c.p, and if you wish to check if certain position p is the selected one, use: p == c.p. Vitalije -- You received this message bec

Re: p.isSelected()

2019-09-15 Thread vitalije
On Sunday, September 15, 2019 at 3:14:56 PM UTC+2, vitalije wrote: > > It seems that p.isSelected is actually never used in Leo core. Most > probably it is just a remnant from ancient times. > Curiously enough, both: p.setSelected, p.isSelected delegate to v.isSelected and v.setSelected. Apart

Re: Automatic git commit on save using entr

2019-09-15 Thread Brian Theado
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, t

Re: Automatic git commit on save using entr

2019-09-15 Thread vitalije
If you precede git command with the '&' g.execute_shell_commands will not wait for command to finish. IOW it will run in the background as you wish. You may wish to use subprocess module on your own and starting process with subprocess.Popen is fast enough, it won't block your main thread for mo

Re: Automatic git commit on save using entr

2019-09-15 Thread vitalije
Also Popen objects have pid attribute if you need it. And also they have methods like terminate or kill. If you want to terminate background process on closing Leo, then you need to register handler on 'end1' event which should call proc.terminate() on the process you have created with subproce

Re: Automatic git commit on save using entr

2019-09-15 Thread vitalije
YMMV, but I had a bad experience with watching files when using Leo. Leo often writes files in two phases and it happened to me more than once that process watching on files take an empty file or not completely written because of this. So, I had to add some latency to watcher. That is why I cam

Re: p.isSelected()

2019-09-15 Thread Robert Cholette
Thank you, indeed comparing a position to commander.p, or as you guys call it, c.p, did the trick. -- 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 leo-editor+unsu

Re: Automatic git commit on save using entr

2019-09-15 Thread Brian Theado
Chris, On Sun, Sep 15, 2019 at 7:11 AM Chris George wrote: [...] > #!/bin/bash > > cd ~/leo-editor > git pull > cd /working/MEGA/leo-files > ./rerun2 ./push & > python3 ~/leo-editor/launchLeo.py $1 $2 $3 > > > Thanks for sharing. [...rerun2 script...] At a glance, that script seems to be perfo

Re: Automatic git commit on save using entr

2019-09-15 Thread Chris George
I use a .desktop panel shortcut to run Leo. I always run it in a terminal window and close the terminal on exit of Leo. > Here is where I'm confused. You are launching rerun2 in the background, so > it will outlast your bash script for sure. Are you saying you close your > console when leo e

Re: Automatic git commit on save using entr

2019-09-15 Thread Brian Theado
Vitalije, YMMV, but I had a bad experience with watching files when using Leo. Leo > often writes files in two phases and it happened to me more than once that > process watching on files take an empty file or not completely written > because of this. So, I had to add some latency to watcher. > T

Re: Automatic git commit on save using entr

2019-09-15 Thread Brian Theado
Ok, thanks for the confirmation. I never close terminal windows and always launch leo with a command on the command-line. On Sun, Sep 15, 2019 at 1:48 PM Chris George wrote: > I use a .desktop panel shortcut to run Leo. I always run it in a terminal > window and close the terminal on exit of Leo

Re: where are the a="xxx" in leo files?

2019-09-15 Thread Matt Wilkie
> > It makes sense : marked nodes, along with the currently selected node as > the file was saved, are now a 'personal' thing only visible to oneself as > they work on a project. makes sense. > There is also `@bool put-expansion-bits-in-leo-files = True` which saves the tree open/closed state.

Re: p.isSelected()

2019-09-15 Thread Edward K. Ream
On Sun, Sep 15, 2019 at 1:04 AM Robert Cholette wrote: > Figured it out myself, made it work with this code (trying to set the > 'selected' property of 'w_ap' if p is the currently selected node): > Good work. I'm not sure I would have been any help. Edward -- You received this message becau

Re: p.isSelected()

2019-09-15 Thread Edward K. Ream
On Sun, Sep 15, 2019 at 8:20 AM vitalije wrote: Curiously enough, both: p.setSelected, p.isSelected delegate to > v.isSelected and v.setSelected. Apart from these delegations no other calls > to any of these methods is found inside Leo core. I haven't searched for > them inside plugins and other

On vacation for about a week

2019-09-15 Thread Edward K. Ream
Rebecca and I will begin a short September trip tomorrow. We'll be back in about a week. I have just completed the present round of work on the beautify and blacken commands. Here is the summary of all the issues. The work is in devel

The beautify and blacken commands are complete for now

2019-09-15 Thread Edward K. Ream
The beautify and blacken now commands work reliably. The code is in devel. There are minor differences between them, discussed below. This page summarizes all related issues. All open issues are marked "Maybe". *blacken vs beautify*