On Wed, Jun 28, 2017 at 2:48 PM, vitalije <vitali...@gmail.com> wrote:

@Edward, I have another question. Where is the point where the actual
reading of Leo document ends and data is transferred in the tree.

 To be more concrete I have found in method getLeoFileHelper of
FileCommands class the following lines:

c.setRootVnode(v)

fc.rootVnode = v

I thought that is what I was looking for, but on my surprise c.setRootVnode
is empty method. It does nothing.

​You have found the spot. At this point, the sax code has set c.hiddenRootNode.


It looks like *both* the statements you show can be eliminated. Not only
does c.setRootVnode do nothing, but fc.rootVnode is never used! I'll clean
this up soon. My apologies for the confusion.

So, how c commander gets the result of loading Leo document?

​Using c.hiddenRootNode, set by the sax read code.​
​ ​
Here is c.rootPosition
​:

def rootPosition(self):

c = self
if c.hiddenRootNode.children:
v = c.hiddenRootNode.children[0]
return leoNodes.Position(v, childIndex=0, stack=None)
else:
return None

If I knew that my prototype will be finished very soon.

​Oh good. We can have a race :-)

I think I know how to make Leo reloadable, without changing Leo's core much.

The timing of this discussion is extremely lucky, as I have just spent lots
of time delving into caching. The plan is as follows:

1. A new *reload-leo* command will write every open Leo outline to a *cache
list*, using a variation of cacher.makeCacheList:

def makeCacheList(self, p):
return [
p.h, p.b, p.gnx,
[self.makeCacheList(p2) for p2 in p.children()]]

The command will also write leoSettings.leo and myLeoSettings.leo
to their own cache lists, if they are not already open.

2. The reload-leo will then do the following:

- set a g.app.reloading flag
- reload all Leo modules
- re-execute all of Leo's startup code, for each previously open outline,
including leoSettings.leo and myLeoSettings.leo.

If g.app.reloading is True, fc.getLeoFile will get *everything* from the
proper complete cache list via a single (recursive) call to
cacher.createOutlineFromCacheList.

Boom. No calls to sax. No need to reload external files. This should be
almost instantaneous.
Because all modules have already been reloaded, all newly-created data
reflect changes to, say, the VNode, Position or Commander classes.

There will likely be other tests against the g.app.reloading flag. The easy
way would be to have Leo re-parse the cached settings file. Later, the
settings themselves (the settings dicts) could be saved and restored.

It's conceivable that this could be done in just a few days...

*Summary*

Caching all open outlines, plus settings files, will allow Leo to
re-execute its *complete* startup logic after reloading all affected
modules. This will allow Leo to update *all* its data structures
*quickly *without
special cases. This is a fascinating possibility.

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.

Reply via email to