Documentation on the proper use of sections in the current version of leo

81 views
Skip to first unread message

Shakeeb

unread,
Jun 22, 2020, 2:09:12 AM6/22/20
to leo-editor

As an old user of leo who has started again with current versions, is it still possible to use <<section>> definitions and references everywhere with  tangle and untangle. These commands are still available but I can't seem to seem to find documentation for section use.

In my recent experiments with sections there is no issue for a <<section id>> which is defined in a child node, but if I try to re-use the definition through the outline (for a repeatable pattern for example), it doesn't work so well. Indeed, I recently got stuck trying, in an @clean file, to re-use a section definition above @others in the the @others nodes, which didn't work.

S

Edward K. Ream

unread,
Jun 23, 2020, 5:06:40 AM6/23/20
to leo-editor
On Mon, Jun 22, 2020 at 1:09 AM Shakeeb <shakeeb...@gmail.com> wrote:

As an old user of leo who has started again with current versions, is it still possible to use <<section>> definitions and references everywhere with  tangle and untangle. These commands are still available but I can't seem to seem to find documentation for section use.

Yes, Leo supports sections everywhere. They are documented here. However, sections should also be documented in Leo's Users Guide, in a chapter called "Markup Reference".  I've just created #1610 for this.

In my recent experiments with sections there is no issue for a <<section id>> which is defined in a child node, but if I try to re-use the definition through the outline (for a repeatable pattern for example), it doesn't work so well. Indeed, I recently got stuck trying, in an @clean file, to re-use a section definition above @others in the the @others nodes, which didn't work.

The typical way is to clone the "reused" definition and move a clone as a child of each node containing a section reference. Does this work for you?

Edward

Shakeeb

unread,
Jun 23, 2020, 9:28:43 AM6/23/20
to leo-editor


On Tuesday, June 23, 2020 at 12:06:40 PM UTC+3, Edward K. Ream wrote

In my recent experiments with sections there is no issue for a <<section id>> which is defined in a child node, but if I try to re-use the definition through the outline (for a repeatable pattern for example), it doesn't work so well. Indeed, I recently got stuck trying, in an @clean file, to re-use a section definition above @others in the the @others nodes, which didn't work.

The typical way is to clone the "reused" definition and move a clone as a child of each node containing a section reference. Does this work for you?


This works, but frankly I find it a little unintuitive. If I define a section at any point in the tree, I would expect that in any body of a child of the section definition node you can naturally refer to the content of the section without having to clone.

For example if I have a block of code which I define in a section <<error cleanup>>, It would be a great to just refer to the <<error cleanup>> in the code of any child nodes without having to clone. From an implementation point of view, it's just a recursive substitution (on rendering).

To be honest, I have never used clones in any project, I tried a few times, but they distracted me from the natural structure of the outline, and there were issues about them back then that irritated me. But that's just me.

Incidentally, there'a nice symmetry with wikis with the concept outline above

<<section>> defined in a node, can be referred anywhere in the body of a node as <<section>> or =<<section>>
[[WikiWord]] defined in a node, using it as WikiWord or [[WikiWord]] can link back to the defining  node.

S



 

Edward K. Ream

unread,
Jun 23, 2020, 11:22:25 AM6/23/20
to leo-editor
On Tue, Jun 23, 2020 at 8:28 AM Shakeeb <shakeeb...@gmail.com> wrote:

The typical way is to clone the "reused" definition and move a clone as a child of each node containing a section reference. Does this work for you?

This works, but frankly I find it a little unintuitive. If I define a section at any point in the tree, I would expect that in any body of a child of the section definition node you can naturally refer to the content of the section without having to clone.

It's the other way around. If you refer to a section, the definition of the section must appear in one of the node's descendants. This behavior is never going to change.

Edward

Félix

unread,
Jun 23, 2020, 5:27:29 PM6/23/20
to leo-editor
Might have other sections with same name elsewhere in the tree, that have different content, so it has to be descendents only. otherwise, making two structures of 'insect' : and ant and a fly, I would have to distinguish section names with <<torso ant>>, <<antenna ant>>, <<torso fly>>, <<antenna fly>> instead of just <<torso>> and <<antenna>> in their respective descendants. 

Shakeeb

unread,
Jun 24, 2020, 2:07:47 AM6/24/20
to leo-editor
 Edward K. Ream wrote:

It's the other way around. If you refer to a section, the definition of the section must appear in one of the node's descendants. This behavior is never going to change.

I wasn't suggesting to change a current feature that is out in the wild (a 10 year transition from python2 to python3, taught us otherwise :-)

However, perhaps one can conceive conceive of an (analogous/orthogonal?) features that fit how programmers already think:

- <<section>> : use abstraction, define later 
- [[WikiWord]] two-way wiki references
- {{variable}} variable substitution -- define once, user later
- ((includes)) transclusion -- define once, include later 

In each of the above the double-bracket type is a headline, and then the magic happens in the bodies.

S
S

Edward K. Ream

unread,
Jun 24, 2020, 8:52:29 AM6/24/20
to leo-editor
On Wed, Jun 24, 2020 at 1:07 AM Shakeeb <shakeeb...@gmail.com> wrote:

 ...perhaps one can conceive conceive of an (analogous/orthogonal?) features that fit how programmers already think:

- <<section>> : use abstraction, define later 
- [[WikiWord]] two-way wiki references
- {{variable}} variable substitution -- define once, user later
- ((includes)) transclusion -- define once, include later 

In each of the above the double-bracket type is a headline, and then the magic happens in the bodies.

Please file an enhancement request, discussing in detail what each should do.

Better yet, you could write a plugin :-)

Edward

T. Vlainić

unread,
Jun 24, 2020, 12:51:14 PM6/24/20
to leo-editor


Leo4.3.PNG

That functionality was present in old Leo versions (around 4.3) with @root-code directive.

Leo4.3_.PNG

Shakeeb

unread,
Jun 24, 2020, 1:07:52 PM6/24/20
to leo-editor
Fair enough :-), I will try to expand on this and write it up. 

S
 

Shakeeb

unread,
Jun 24, 2020, 1:10:11 PM6/24/20
to leo-editor


On Wednesday, June 24, 2020 at 7:51:14 PM UTC+3, T. Vlainić wrote:


Leo4.3.PNG

That functionality was present in old Leo versions (around 4.3) with @root-code directive.

Leo4.3_.PNG



 Thank you for that. For a moment, I was confused about whether I experienced the feature or not (-:

S





 

Edward K. Ream

unread,
Jun 25, 2020, 12:18:18 PM6/25/20
to leo-editor
On Wed, Jun 24, 2020 at 11:51 AM T. Vlainić <tvla...@gmail.com> wrote

> That functionality was present in old Leo versions (around 4.3) with @root-code directive.

The @root code still exists to support existing code. However, its documentation has (on purpose) been removed. So you could say this feature has been deprecated.

Edward
Reply all
Reply to author
Forward
0 new messages