@settings trees may now contain @outline-data nodes.  These nodes, and 
their descendants, can be used to pass entire outlines as the value of 
c.config.getOutlineData.  Details below.

Leo's abbreviation manager now uses settings of the form::

    @outline-data tree-abbreviations

to create abbreviations that expand into *outlines* when they fire.  When 
such tree abbreviations fire, Leo pastes the nodes of a the abbreviations 
outline as children of the node that is selected when the outline fires.

Here's how it works.  The body text of the @outline-data tree-abbreviations 
node contains the names of the tree abbreviations, each on a separate 
line.  Like this::

   abc;;
   xyz;;

As with @data nodes, Leo ignores any line starting with '#'.

For each abbreviation name, there should be corresponding child node, the 
**abbreviation node** whose headline matches the abbreviation name.

In this example, the @outline-data tree-abbreviations node should have two 
(direct) children, whose headlines are abc;; and xyz;;  So these are the 
two abbreviation nodes.

When the abc;; abbreviation fires, Leo pastes the *children* of the abc;; 
node as the children of the selected node.  (Any pasted nodes follow any 
existing children).

That's it.

leoSettings.leo contains an example node:

    @@outline-data tree-abbreviations examples

To make this node active, rename it to::

    @outline-data tree-abbreviations

Edward

P.S. Here are some implementation notes.  Feel free to ignore.

I got tree abbreviations working yesterday with a series of  hacks that 
bypassed Leo's default settings priority mechanism.

Then I had an Aha.  Suppose the *value* returned by (a new) 
c.config.getOutlineData  was the xml string created when Leo pastes the 
@outline-data node **itself** to the clipboard!

This was a stroke of genius, if I do say so myself.  Leo can then use all 
the standard configuration code for @outline-data settings!  That is, 
settings in a local file override myLeoSettings.leo settings, which 
override settings in leoSettings.leo.

Of course, the "consumer" of c.config.getOutlineData must then paste the 
xml string into the outline.  Like this::

    c.fileCommands.leo_file_encoding='utf-8'
    p = c.pasteOutline(s=tree_s,redrawFlag=False,undoFlag=False)

The consumer must then use the pasted outline in some way.  For tree 
abbreviations, abbrevCommandsClass.init_tree_abbrev pastes the outline, 
uses the outline to define abbreviations, and then *deletes* the tree.

Still, this is a general pattern:  we have now expanded the notion of 
settings to include full outlines!!

P.P.S.  The redrawFlag and undoFlag keyword args to c.pasteOutline are 
new.  They ensure that operations happening at startup time do not cause 
unwanted side effects.

EKR

-- 
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