A design decision was made in Leo that if you alter the heading/body of any 
parent of an @<file> node that this node will be marked dirty, ie it will 
be written to disk when saving the .leo file. After discussion I agree it's 
the safest option.

However, when using chapters and organizational nodes this can be 
troublesome because adding @chapter to an organizer node at a high level 
will mark any files in that subtree dirty. If you have tens, hundreds, or 
even thousands of @<file> nodes under a single organizer node it could be 
painful to have to resave all those files unnecessarily. In my case I 
access files over a slow VPN and renaming a chapter could result in a 10 
minute wait while hundreds of files get saved.

I don't have an elegant solution but I do a simple one which I think is a 
good demonstration for teaching Leo scripting as well. My solution is a 
button:

Headline:
@button mark_subtree_clean

Body:

for node in c.p.self_and_subtree():
    node.clearDirty()
    
c.redraw()

Hitting the script-button on this node will create a button on the toolbar. 

This small script does a simple thing, but satisfies an important function 
for me. It took me a few minutes to write (I spent most of that time trying 
to guess the name of the function which provided the list of all nodes in a 
subtree) but it saves me time whenever modify the names of my @chapter and 
organization nodes.

-- 
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 post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to