I used my freemind to Leo script to import a big mindmap into Leo.
The script sticks the entire contents of a freemind node into the
headline of the corresponding Leo node.  For long freemind nodes, this
results in leo nodes with really long headlines.  I decided I wanted
to break up these leo nodes with long headlines into multiple nodes.
I came up with the following script button (which seems to work).  But
I ran into trouble trying to get undo working with it.

One thing that confused me is that the beforeChangeGroup method takes
a position as the first parameter.  Is this supposed to mean that I am
making a bunch of changes to just that one node?  What if I wanted to
make a bunch of changes to a bunch of nodes and I didn't know which
(or if any) would be affected -- then what would I pass as that first
parameter to beforeChangeGroup?

Anyway, I tried this and it pretty much works as expected, except when
I hit undo the body of the node above the node who's headline I'm
reverting disappears.  My test case is like so:

Create a new leo outline.
Make the NewHeadline node a script button with the following contents:
--------
u = c.undoer
undoType = "Break up long headline"
u.beforeChangeGroup(c.p,undoType)
for p in c.allNodes_iter():
    g.es("p.h: ", p.h)
    split = p.h.split("  ", 1)
    g.es("split: ", split)
    if len(split) <= 1:
        continue
    before, after = split
    undo_data = u.beforeChangeNodeContents(p)
    p.setHeadString(before)
    u.afterChangeNodeContents(p, "Changed Headstring", undo_data)
    child = p.insertAsLastChild()
    child.setHeadString(after)
u.afterChangeGroup(c.p, undoType, reportFlag=True)
c.redraw()
-----------
Then, add a new top-level node with the following headline:
-----------
Test headline.  Test headline.  Test headline.  Test headline.
-----------
(note that's two spaces after each period)
Select the NewHeadline node (the one that has been made into a
button).
Click the script button.
Hit ctrl+z.
The body of the node has disappeared.

I'm not sure if this is a leo bug or just me doing the undo stuff
wrong.  Clarification would be appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to