Leo : Basics Derived Files Part 2 |
Leo has a second way of creating derived files. This is the @file directive. This directive at first seems similar to the @root directive, but there is an important conceptual difference. When you use the @file directive, outline information is always written to the derived file. Therefore, you cannot use the @silent directive.
The benefit of using the @file directive is that there is no longer any need to explicity tangle and untangle. Tangling and untangling happen automatically by opening a .leo file and saving it. This makes alternating between Leo and another editor or IDE completely transparent.
In addition, when you use the @file directive, you can have unnamed sections. To see how these work, read on...
Here we've added a second node with a @file directive to our tree from the previous tutorial. The @file directive, in contrast to the @root directive, appears only in a node headline, not in node text.
As before, the node text has the << includes >> section name. But this time, instead of a << methods >> section name, it has a new directive: @others. This directive means, "put the node text from all of the unnamed sections here." Unnamed sections are nodes that are not sections, i.e. nodes that do not have double angle brackets in the node headline.
We enter [CTRL-S] to save our .leo file, and the sampleHello2.c file is automatically written.
Here is the sampleHello2.c file in our text editor. Embedded outlines created with the @file directive have a different embedding format than those created with the @root directive.
All of the outline information embedded by Leo starts with the @ sign (plus, in this case, two slashes). Needless to say, we can't delete any such sentinel line without interfering with the ability of Leo to read the file back into an outline.
Let's try adding some code in the text editor.
Next we save the file with the text editor.
When we return to Leo, we do not see the changes. We must either reopen the file or reread it.
When we reopen our sample2.leo file, we can see that the changes we made to sampleHello2.c have been incorporated into our outline in the proper place.
If you are a programmer, you now have all of the information you need to start using Leo with your own programs. You may find that Leo quickly brings about a great improvement in programming speed and enjoyment, both for your own projects and for team projects.
For a look at some sample projects that have used Leo successfully, see the Examples section in this tutorial series.