ENB: building Leo into emacs org mode

43 views
Skip to first unread message

Edward K. Ream

unread,
Aug 2, 2019, 8:58:19 AM8/2/19
to leo-editor
Something in the recent conversation with John R created several Ahas:

Aha 1: There is no need to "invent" a Leonine gui for emacs: org mode's "gui" would suffice.

Aha 2: Adding Leonine features to org mode would be a task for an Emacs Champion.

I have no plans to write the required elisp code.  Indeed, it would be a big distraction for me and Leo's other devs.  However, I am willing to support such efforts with design suggestions.

#1026: Embed Leo in Emacs has been closed and marked "won't do".  I am considering revising and reopening it.

The rest of this post is an Engineering Notebook post, discussing how such a thing might be done.  It will pre-writing for a revision of #1026.  As always with ENB posts, feel free to ignore it.

Overview

Leo's major features are clones, generators, Leonine directives, @<file> directives and the Mulder-Ream update algorithm, @test, etc.  It would be good to inject something like c and p into elisp scripts.  Here are the tasks as I see them:

Support Leonine clones

Imo, there is hardly any reason for this project if the enhanced org mode did not support clones.

It would be straightforward to add a "leo-gnx" field to an (org-mode) drawer when creating the node. But that's the easy part.

Leo's DAG is highly optimized.  It is the result of decades of evolution. Supporting clone operations in org mode might take one of several forms:

1.  Adding a clone copies the cloned tree to another part of the tree.  This has serious performance problems.

2. Create a "shadow dag" representing the entire tree.  This would require a substantial revision of all parts of org mode.

Support Leonine generators

Org mode uses filters to "traverse" an org-mode file.  In most cases, those filters could "deliver" only one copy of each cloned node.  There are many design issues here, and they depend on the representation of clones.

Support @<file> nodes

Org babel is great for code snippets.  It does not scale up to entire source files.  @clean requires a re-implementation of the Mulder-Ream update algorithm in elisp.  That would not be a big deal using difflib.el.

Supporting section references would be another major project.  Strictly speaking, it is not essential, but it might as well be done if @file and @clean are supported.

Summary

Embedding Leonine features into org mode would be a huge project.  I am, on principle, not going to do it, but I would be happy to support the work of an Emacs Champion willing to take on the project.

Org mode already supports the crucial separation of node headlines and bodies.  That is, p.h and p.b are (or could be) well defined.  This means it would be possible to support "heritable" Leo directives.  In fact, org mode probably has something similar.

Creating a true DAG of (elisp) nodes would simplify many aspects of the implementation.  Keeping this DAG in sync with the visible org-mode pane would be a challenge, but the alternatives are likely much worse.

All comments and questions are welcome.

Edward

Edward K. Ream

unread,
Aug 2, 2019, 9:13:17 AM8/2/19
to leo-editor
On Friday, August 2, 2019 at 7:58:19 AM UTC-5, Edward K. Ream wrote:

Org babel is great for code snippets.  It does not scale up to entire source files. 

One could consider allowing @others and section references within <body> part of code blocks:

#+NAME: <name>
#+BEGIN_SRC <language> <switches> <header arguments>
  <body>
#+END_SRC

Edward

Edward K. Ream

unread,
Aug 2, 2019, 10:11:06 AM8/2/19
to leo-editor
On Fri, Aug 2, 2019 at 7:58 AM Edward K. Ream <edre...@gmail.com> wrote:

> I have no plans to write the required elisp code.  Indeed, it would be a big distraction for me and Leo's other devs.

If I had understood emacs way back in 1985 I would likely have written something like org mode myself.  Leo's history would surely have been very different.  Leo's user base would have been larger, but who knows whether either of the following would have happened:

1. e's dyna_menu, which lead to @button.
2. Bernhard Mulder's @shadow, which lead to @clean.

Anyway, we do have @button, @clean and all the rest.  Embedding Leonine features into (say) org mode might be the most effective way of spreading the Leonine way, and btw, getting all the benefits of emacs.

If I had a magic wand and could soup up org mode with Leo I would certainly do it.  It would be even better if emacs could get its act together and allow scripting emacs with python ;-)

But I don't have a magic wand, and it doesn't seem likely that emacs will ever be scriptable with python.  Unless some hero steps up Leo in emacs will remain a tantalizing possibility, just out of reach.

Edward
Reply all
Reply to author
Forward
0 new messages