In praise of @outline-data tree-abbreviations

72 views
Skip to first unread message

Largo84

unread,
Mar 14, 2017, 11:07:12 PM3/14/17
to leo-editor
Not sure if this abbreviation/template has been around awhile and I just missed it, or if it's new, but it's almost exactly what I've been looking for to create template documents. It will save me a lot of time over my previous method of copying template nodes, then manually editing the variables.

Now if only the node headlines can be created from placeholder variables, it would be perfect. I believe there's a ticket on git for that very thing.

If you haven't seen this in action, check it out, it's pretty cool!

Rob.........

Edward K. Ream

unread,
Mar 15, 2017, 11:32:47 AM3/15/17
to leo-editor
On Tue, Mar 14, 2017 at 10:07 PM, Largo84 <lar...@gmail.com> wrote:

Now if only the node headlines can be created from placeholder variables, it would be perfect. I believe there's a ticket on git for that very thing.

​Hehe.  I know what you're doing--trying to get this into 5.5b1 using the nefarious tactic of sincere praise.  I'll see what I can do.

No guarantees though, messing with headlines is tricky due to focus problems.  I'll do the work in an abbrev branch so you wont' have to wait for an official release.

Edward

Largo84

unread,
Mar 15, 2017, 12:03:04 PM3/15/17
to leo-editor
I'm so busted, can't sneak anything by you:-) 

Eric S. Johansson

unread,
Mar 15, 2017, 6:16:06 PM3/15/17
to leo-editor


On Wednesday, March 15, 2017 at 11:32:47 AM UTC-4, Edward K. Ream wrote:
I was thinking about something similar for my programming with speech recognition extensions. The idea is you have a template which is cloned and each template has a subsection which refers to local values or methods for template variables. When I was playing around with this a while back, I found that a recursive template expansion was incredibly powerful for making reusable templates without any flow control.

Edward K. Ream

unread,
Mar 15, 2017, 6:59:25 PM3/15/17
to leo-editor
On Wednesday, March 15, 2017 at 11:03:04 AM UTC-5, Largo84 wrote:
I'm so busted, can't sneak anything by you:-) 

Fixed at e4e2fb8 of the abbrev branch.  Let me know how it works for you.

Edward

Largo84

unread,
Mar 15, 2017, 10:18:04 PM3/15/17
to leo-editor
Some small tests suggest it will work fine. That was fast, excellent work!

Rob..........

Largo84

unread,
Mar 15, 2017, 10:41:19 PM3/15/17
to leo-editor
One observation that might help others and also the documentation. In a 'regular' abbreviation, to create a new line, the syntax is:

foobar;;=<|Foo|> hangs out at the <|Bar|>
\:Another line of <|baz and blah|>
\:Yet another line of <|blah|>.

Quite a different story in @outline-data tree-abbreviations, as in:

In the child node that defines the template, the proper syntax for foobar;; is:

<|Foo|> hangs out at the <|Bar|>
Another line of <|baz and blah|>
Yet another line of <|blah|>.

Otherwise the `\:` characters are written as if they are part of the expansion.

It's not a big deal once I figured that out, but it is a different approach.

Rob........

Edward K. Ream

unread,
Mar 17, 2017, 12:33:21 PM3/17/17
to leo-editor
On Wednesday, March 15, 2017 at 5:16:06 PM UTC-5, Eric S. Johansson wrote:

I was thinking about something similar for my programming with speech recognition extensions. The idea is you have a template which is cloned and each template has a subsection which refers to local values or methods for template variables. When I was playing around with this a while back, I found that a recursive template expansion was incredibly powerful for making reusable templates without any flow control.

Intriguing. Given the complexity of Leo's abbreviation code, I suspect this won't happen "natively" in Leo.  But scripts can do anything...

Edward

Edward K. Ream

unread,
Mar 17, 2017, 12:34:47 PM3/17/17
to leo-editor

Many people, myself included, would be interested in whatever script or @button node you create.

Edward

123 456

unread,
Mar 18, 2017, 4:58:41 PM3/18/17
to leo-editor

I'm sure.  How/what docs do I get only the code part of a section? Is there a way to associate data in a section with one or more sections. Idea is a section can hold a bi-directional dictionary. Is there a way for a section to show raw and rendered views?


--
You received this message because you are subscribed to a topic in the Google Groups "leo-editor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leo-editor/InLnBRt6m_g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leo-editor+...@googlegroups.com.
To post to this group, send email to leo-e...@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Edward K. Ream

unread,
Mar 19, 2017, 5:51:58 AM3/19/17
to leo-editor
On Sat, Mar 18, 2017 at 3:58 PM, 123 456 <ynotla...@gmail.com> wrote:

How ... do I get only the code part of a section?

​I'm not entirely sure what you mean by "section". The answers below assume you mean a Leo node.

The answer to all such questions is to look for helpers in Leo's code related to the topic. leoGlobals.py is a good place to start looking.

For all scripting-related issues, start looking in:

    @file leoGlobals.py-->g.Scripting

You could have found this section by looking for the 'execute-script' command. Do this by searching for 'execute-script', including the single quotes.  You will find c.executeScript.  It does a lot of things, but first it calls g.getScript.

g.getScript has two helpers.  g.extractExecutableString is probably what you want.  Its docstring is:

     '''
    Return all lines for the given @language directive.
   
    Ignore all lines under control of any other @language directive.
    '''

To find a node with a given section name, you can start looking in leoAtFile.py. In the node:

    @file leoAtFile.py-->class AtFile-->at.Writing-->Writing 4.x utils...

you will find at.findSectionName. This scans text looking for << section name >>.

In the node:

    @file leoAtFile.py-->class AtFile-->at.Writing-->Writing 4.x-->
    writing code lines...-->putRefLine & allies

you will find at.findReference, which searches a tree for a section definition node.  This calls g.findReference, so once again we are back to a function in leoGlobals.py.

Is there a way to associate data in a section with one or more sections. Idea is a section can hold a bi-directional dictionary.

The answer will probably involve uA's. ​These user attributes can be attached to any node using p.u = aDict.

Is there a way for a section to show raw and rendered views?

Again, I'm not sure what you mean by a section.  If you mean "the body text of a node", then your script can create reStructuredText or markdown text whose effect will be to show raw and rendered views.  Your script could also create several nodes.

HTH. Please feel free to ask other questions.

Edward
Reply all
Reply to author
Forward
0 new messages