Leo : Basics    What is Leo  

Page 1


Leo is a unique, powerful computer program that you can use to organize, analyze and describe text and text files. Leo is a free program written by Edward K. Ream. For information about downloading Leo, see installation  tutorial in this series. Leo runs on Windows, Mac, or Linux.

Use Leo:

  • to brainstorm a new project
  • as a Personal Information Manager
  • to add multiple outlines and commentary to any text file
  • as a tool to facilitate a new kind of literate programming.

Because Leo is unlike other tools you may have used, a series of examples may be the best way to demonstrate what can be done with Leo.





Page 2


From one perspective, Leo is an outlining editor . This is a screenshot of Leo. You create an outline in the top left pane. (A later tutorial explains how to create an outline like the one in the screenshot).

  Click on the image for page view.




Page 3


Clicking on the indicated box will open the indicated node .

  Click on the image for page view.




Page 4


Here the node has been opened. Clicking on the box again will close the node.

  Click on the image for page view.




Page 5


Here the indicated node has been closed.

  Click on the image for page view.




Page 6


Clicking on a node headline (1) will show the text for that node in the body pane (2) below. The body pane is a text editor - you can enter, delete or change text here by typing it in.

  Click on the image for page view.




Page 7


You can save the outline in a leo file. Click File - Save.

  Click on the image for page view.




Page 8


Here we will save our outline in a file name "pim.leo".

  Click on the image for page view.




Page 9


The file is now saved, and the file name appears in the title bar.

  Click on the image for page view.




Page 10


You've just seen an introduction to Leo as an outlining editor. You can use Leo to make an outline, with optional text for each outline element. You can save the outline to a file. Outlines are explained more in a later tutorial in this series. The outlining capability of Leo goes far beyond what has just been demonstrated, including multipath outlines, and multiple outlines in one file .

What we've shown so far is no different from other outlining editors. What makes Leo unique is the addition of a new feature. Using simple directives, you can instruct Leo to extract text from any number of nodes, in any order, and write the text to a new file. You can also embed outline information in the second file, giving Leo the ability to read the text pieces back into the Leo outline, even if they have been changed.

In effect, Leo is a meta-text editor . It gives you the ability to create a structural document for a non structured document, or a document that is structured in some other way.

What does this mean in practice? Some examples should help clarify things...

 





Page 11


Here is the "pim.leo" file again. We've:

  1. Selected the "2000" node.
  2. Entered a couple of directives. The second (@root) tells Leo the file name that we want to derive (extract to). (The @silent directive is explained in a later tutorial).
  3. Entered some node text.
  Click on the image for page view.




Page 12


Now we tell Leo to tangle the node. This means Leo should 

  1. Start at the current node and look for a @root directive.
  2. Create the file named in the @root directive or open it if it already exists.
  3. Write all of the node text to the file named in the root directive.

Why is this operation called tangling? We'll see that a few pages from now.

  Click on the image for page view.




Page 13


Leo has derived the file (written the file to the hard disk).

  Click on the image for page view.




Page 14


Here the file is listed in Windows Explorer.

  Click on the image for page view.




Page 15


And here is the file displayed in a text editor.

  Click on the image for page view.




Page 16


That example wasn't very interesting. All that we extracted was the text "This is my diary." We'll probably want to extract more than that.

In fact, when tangling, we can extract not only the node text as we just saw, but also all or part of the text of any subnode. And we can put these extracted pieces into the derived file in any order. That is why the process of extraction is called tangling.

Let's try this. Select the "Jul" node.

  Click on the image for page view.




Page 17


  1. We add << >> angle brackets to the headline. This tells Leo that the node is a section.
  2. We add the @c directive. This tells Leo where to start extracting text from this node.
  Click on the image for page view.




Page 18


Now we go back to the 2000 node. We enter the section name << Jul >> into the node text where we want the << Jul >> section text to be output. When tangling, Leo will replace this section name with the section text. This operation is recursive, so if a section text contains a section name, this also will be replaced with the named section's text.

Note: when we put a << section name >> into node text, the section name must correspond to a section located under the current node. Leo only looks in subnodes for section names.

  Click on the image for page view.




Page 19


Choose Tangle.

  Click on the image for page view.




Page 20


The file has been updated.

  Click on the image for page view.




Page 21


Here is the extracted file viewed in a text editor.

  Click on the image for page view.




Page 22


This tutorial has given you a brief introduction of Leo's:

  • Outlining capacity
  • Ability to create derived files.

These two things are the main features of Leo. However, there is much more to say about both of them:

  • Outlining - see the Outlining tutorial in this series to see how Leo can be used to create outlines with multiple paths or views, making it a powerful tool for project planning or any kind of tree-based analysis.
  • Derived files - we've seen the simple case of deriving a text file from a set of nodes. This gives  you the ability to collect a number of text files in one Leo outline. It also allows you to  associate an outline with a separate text file. But Leo can not only extract a text file from an outline, it can embed an outline in a text file and read it back. For more about this feature, see the next tutorial in this series: What is Leo - Continued. In addition, in the following tutorials you will see much more complex examples of derived files.
  • Literate Programming - the ability to associate an outline and extra text with a text document means that you can write a program outline in English at any level of detail, then add your code to the outline, and then tangle the code into a separate program file. The English documentation of the program becomes a primary structural component. For more about Leo and Literate Programming, read on in this set of tutorials, particularly the Examples section.




Page 23


Additional features of Leo of interest to advanced users:

  • Can be scripted with Python.
  • Contains a syntax highlighting programmer's editor.
  • The .leo format is XML, meaning that a leo file can be easily converted to any other text format such as HTML.

For more information about these features, see the Leo documentation included with the Leo program.

 




Text Author: Joe Orr   Creative Commons - Non Commercial - Share Alike