Hmm, I've tinkered it down to this and it's just been working on my system:

filename = c.fileName()

if len(g.app.commanders()) == 1:
    c.doCommandByName('restart-leo')
else:
    c.doCommandByName('close-window')
    g.openWithFileName(filename, old_c=c)

It may not seem to do anything if there are more than one open outlines 
because it's so fast. Bear in mind that this code doesn't add or change the 
layout setting. This command would be executed after the layout setting had 
been updated. This code just demonstrates how to do the reload part of the 
task.  You could edit the layout setting by hand before reloading to 
demonstrate that it works.

The first branch, the one for just one open outline, does a full restart of 
Leo, which I hate because it's slow and disruptive. I tried opening a new 
empty temporary outline, then reloading the first one, then closing the 
temporary one, but I can't figure out how to close the temp outline without 
invoking the save dialog. 

If the save dialog for closing the temp outline could be avoided, the whole 
thing would happen so quickly that temporary outline's brief presence 
wouldn't be very disruptive, especially compared with a full restart. But 
Leo's code for saving and closing an outline would have to be refactored, 
and my quick-and-dirty efforts haven't worked yet.  Well, I didn't actually 
refactor anything, I just pulled together the minimal bits of existing code 
I thought should work.  But no.
On Friday, August 30, 2024 at 10:20:50 PM UTC-4 Edward K. Ream wrote:

> On Friday, August 30, 2024 at 5:39:16 PM UTC-5 tbp1...@gmail.com wrote:
>
> I just discovered this.  The shadow opened exactly on top of the other, so 
> I didn't realize it was there.  That should be fixable, I think.  And if 
> not, the previous version of the script works.
>
>
> The previous version does not work for me. Neither branch of the "if" 
> statement works in general. 
>
>      filename = c.fileName()
>     if len(g.app.commanders()) == 1:
>         # c.doCommandByName('restart-leo')
>         # c.redraw()
>         c.restartLeo()
>
>     else:
>         c.doCommandByName('close-window')
>         g.openWithFileName(filename, old_c=c)
>         c.redraw()
>
> Edward 
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/a9003cc3-e2ab-40b9-836f-4670e16cc5aen%40googlegroups.com.

Reply via email to