Thank-you. I replaced
if c.isChanged(): c.save() in the @button with the new code and it works flawlessly. This is very useful to me. It not only allows me to write discrete commit messages, it taught me a bunch about scripting in Leo. Chris On Sunday, February 11, 2018 at 1:58:44 AM UTC-8, Edward K. Ream wrote: > > On Saturday, February 10, 2018 at 9:12:08 PM UTC-6, Chris George wrote: >> >> The @button saved the .leo file, triggering the save of the text file as >> well. Fossil picked up both changes. >> >> Is it possible to write the @clean node to disk without saving the .leo >> file? >> > > Sure. The only question is how much work it will take ;-) > > *Background* > > - leoFileCommands.py contains the code that writes .leo files. > > - leoAtFile.py contains the code that writes @<file> nodes of all kinds. > This is distinct from the code in leoFileCommands.py. > > - at stands for c.atFileCommands in Leo's headlines and code. > > Surprisingly, there is no at.writeOneAtCleanNode function. Instead, > at.writeAllHelper contains this code: > > elif p.isAtCleanNode(): > at.write(p, kind='@clean', nosentinels=True, toString=toString) > > at.writeAllHelper ends with this code: > > for p2 in p.self_and_subtree(): > p2.v.clearDirty()c.redraw() > > Arguably, the AtFile class should contain this helper: > > def writeOneAtCleanNode(self, p, toString=False): > at = self > at.write(p, kind='@clean', nosentinels=True, toString=toString) > for p2 in p.self_and_subtree(): > p2.v.clearDirty()c.redraw() > > *The code* > > Let p be the position of the @clean node you want to write. > > The following is tested code that writes p without writing the .leo file: > > at = c.atFileCommands > at.write(p, kind='@clean', nosentinels=True, toString=False) > for p2 in p.self_and_subtree(): > p2.v.clearDirty() > c.redraw() > > The redraw shows that: > > - the dirty bits have been cleared in the @clean tree. > - the outline's changed status, c.isChanged() has not changed. Imo this is > correct. > > HTH. > > 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 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.