On 10/23/2013 10:58 AM, Edward K. Ream wrote:
On Wed, Oct 23, 2013 at 8:54 AM, Jacob Peck <[email protected] <mailto:[email protected]>> wrote:

>
So, I wrote a function that will create a hierarchy of nodes with a list of given headlines.

Interesting.

>
With the proper undo code added, I think that it would be right at home as c.create_node_hierarchy
...

I agree.

>
I would find this immensely useful in the API. Currently I have to redefine it in each outline I want to use it in.

No, you don't.  Just add an @command node in myLeoSettings.leo::

    + @settings
+ @commands
+ @command create-hierarchy


That doesn't help... it takes parameter arguments (heads, most importantly). It's meant to be used in scripts. Unless @command nodes add themselves to c...
>
I'd add it myself, but I don't understand the undo code for the life of me...

As a fairly advance Leo script writer, it's time for you to mine Leo's source code for patterns. This is what I do.

The clone-find-all command creates a tree of nodes, so it would be a good place to look. After a bit of searching, I found:

    @file leoFind.py-->class leoFind-->Find/change utils-->
    findAll & helper (leoFind)

Take a look at this node.  The pattern is, in essence::

    u = c.undoer
    undoType = 'Name of command, for the undo menu'
    ...
    undoData = u.beforeInsertNode(c.p)
    found = self.createCloneFindAllNode()
    ...
u.afterInsertNode(found,undoType,undoData,dirtyVnodeList=[])

Your code will be something similar. There is no need to understand the undo code in detail.

Give it a try, and feel free to ask questions. This will never be in the tutorial, and even if it were, you're ready to fly on your own now.

When I have time I'll give it a go.

-->Jake
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to