How do I learn leo for non-python programming

54 views
Skip to first unread message

cafea

unread,
Jan 15, 2014, 9:07:25 PM1/15/14
to leo-e...@googlegroups.com
I just installed Leo under Windows 7, because I have a c++ project I want to start and I was hoping to use a literate-programming style and after lots of searching, I get the impression that leo is pretty much the only relatively full featured IDE that supports that.

The tutorials seem to all be about python programming though and I've never used python.

Is leo capable of handling C++ projects?

I notice that "Leo Cheat Sheet"->"Leo Directives" has an entry
@language c
is that what I'd use, or should there be a setting specific to C++?

Should I just work my way through the leo tutorial for python and learn python if I want to use leo for C++?

I'm not really sure where to start.

Also I noticed a couple problems with installation under Windows 7
Unchanged, the click installer makes a start menu item that doesn't work.  I had to change "pythonw" to "python" for it to work, even though both are in the Python33 directory

Also I had to change it "run as administrator" so it didn't complain about not being able to write to the spelling files, though I suspect that running it in XP compatible mode would also have fixed that problem.

Josh

Edward K. Ream

unread,
Jan 17, 2014, 6:32:18 AM1/17/14
to leo-editor
On Wed, Jan 15, 2014 at 8:07 PM, cafea <cafea...@gmail.com> wrote:

Is leo capable of handling C++ projects?

​Certainly.  Early versions of Leo were written in Borland C contained in a Leo outline.​
 

I notice that "Leo Cheat Sheet"->"Leo Directives" has an entry
@language c
is that what I'd use, or should there be a setting specific to C++?

​Use @language cplusplus​
 

Should I just work my way through the leo tutorial for python and learn python if I want to use leo for C++?

Good question!  There are actually very few lines of Python code in the tutorial at: http://leoeditor.com/tutorial-programming.html

The main thing to understand is that Leo's markup (@others and section references) works for *all* languages. The tutorial doesn't make this clear.

Try this:

1. Create a node whose headline is @file hello.cpp and whose body text is::

    @language cplusplus
    (the text of hello world in c++)

2. Save the outline and look at the resulting file, hello.cpp.

3. Now add @others and section references, as in the tutorial, but use C++ code instead of Python code.  Everything should just work.

To support @others and section references, the *only* thing that Leo needs to know about any language are its comment delimiters. That's what @language cplusplus does. (The @language directive also controls syntax coloring.)

In other words, the code that handles @others and section references knows *nothing* about the syntax of any language.  (Leo's importers, used by @auto, *do* know about language syntax, but that is a completely separate matter.)

HTH.  Please feel free to ask more questions.

Edward

P.S. Because the code that handles section references knows nothing about language syntax, you have to be careful with C++ << and >> operators.  Don't put them on the same line: Leo will think they denote a section reference.  This is true also of Python code.  It usually doesn't matter, but then I don't write a lot of mathematical code...

P.P.S. When you get more experience with Leo, you could try your hand at writing an @button script that will execute the body text of the selected node (and its descendants!) as a C++ script ;-)  Leo should already have such a thing, but at present it doesn't.  It would be patterned after the code in c.executeScript.

EKR
Reply all
Reply to author
Forward
0 new messages