"Far away in the heavenly abode
of the great god Indra,
there is a wonderful net
which has been hung by some cunning artificer
in such a manner that it stretches out
infinitely in all directions.
In accordance with the extravagant tastes of deities,
the artificer has hung
a single glittering jewel
in each eye of the net,
and since the net itself is infinite,
the jewels are infinite in number.
There hang the jewels,
glittering like stars in the first magnitude,
a wonderful sight to behold.
Were we to select one of these jewels for inspection,
we would discover that in its polished surface
there are reflected
all the other jewels in the net,
infinite in number.
If we look still more closely,
we would see that each of the jewels reflected in this one jewel
reflects all the others."
This is the metaphor of Indra's Net,
which is told in some schools of philosophy.
Let's keep this metaphor in mind,
because it'll help us understand
the Emacs extension that we're about to discuss.
In editing text, there's two main paradigms:
one is editing at the ground level,
where the characters that we type
actually appear on the screen,
the changes we make actually occur.
The other editing paradigm
is where we escape to a higher level
and now the characters that we type are not...
They don't actually appear on the screen
because we're not at the ground level with the text,
we are at a higher level
looking down at the text
and regarding the text,
referring to this world of text in terms of a language.
For instance, we could describe this
world as having words and paragraphs and sentences and lines and so on.
We could reason about this text
in terms of these textual entities and this textual language.
This is the second paradigm of text editing.
When we're in the second paradigm,
there is a way to go down to ground level.
You hit Enter now--or we'll hit Enter to go down to the ground level,
and you can hit Escape
to go back out to the referential level.
Enter to go down to ground level
and Escape to go up to the referential level.
Now, in Vim, the nouns in this world of text
all share the same referential plane which we call normal mode.
So in normal mode, all of the nouns
of the world of text are available,
whether it's words or sentences or paragraphs,
and they all share this same referential plane.
They compete for space on the keyboard.
An alternative way to structure these modes is
instead of having a single mode where all the nouns coexist,
peacefully or otherwise,
you instead have a dedicated mode for every noun.
In that case, what happens is
because your modal spaces are now much smaller,
you're just talking about words or paragraphs or lines or something,
the keys that you use
can be much more targeted.
You can use the same keystrokes
in all of your modes and they would have
the same ideas behind them,
but they would have different effects
depending on which context you're using.
It's the same keystrokes, different contexts.
The advantage of that is it's often easier to change context
than it is to learn new key bindings.
So let's see an example of how that works.
We go into character mode, and if you look at the mode line
at the bottom of the screen there,
you'll see that we're in character mode.
Now, when we move up, down, left, and right,
we're moving by character.
We can also transform the text,
and the transformations occur in terms of character.
You can also go into word mode.
In word mode, the transformations that you do are on words.
and you try... Your movement is also in terms of words.
So that's the level of granularity that you have.
You could also go to line mode.
When you're in line mode,
you go up and down by line,
and you can move lines
up and down left and right and so on.
The transformations you do are in
terms of lines.
You could also go to window mode,
where now the objects that you're referring to are windows.
You can move spatially amongst the windows
or do transformations on the windows
using the same keystrokes.
So let's go to...
Right. One of the things,
the principles at play here
is something called the Rumpelstiltskin principle,
which is something that's known in computer science.
If you can name something,
then you have power over it.
This is kind of an adaptation of that principle
which says that if you can name something
and if you can talk about it,
then it's a noun in your editing language.
If it's a noun, then it has...
It's a mode. So if we can talk about it, it's a noun.
If it's a noun, then it's a mode.
One of the things we've been talking a lot about is modes.
In fact, by this principle,
modes also should be a mode.
You should have a mode that can reason
in terms of modes as objects,
just like you have modes
where you can reason in terms of
words or lines as objects.
So let's do that. Let's go to mode mode.
When you go to mode mode, you see that
the objects that are depicted here
are the modes that are present in the buffer,
which we knew about because
the style of editing that we had in this buffer
was the Vim style of editing
where there's an insert mode at the ground level
and a normal mode that you can escape to.
You insert, enter the ground level.
Enter to the insert mode and escape to normal mode.
When you look at the mode mode representation,
you see that in fact that
is the structure that's depicted.
But in different situations, you might find
that these modes are not the
ones that you want.
You want something more tailored for the specific application.
For instance, if you're editing Lisp code
(or code in general, but
Lisp code is a particular example),
you might want to take advantage
of the structure of the code.
For Lisp code in particular,
we have a mode called symex-mode
which is able to reason about your code
in terms of its tree structure.
So you can use the same keystrokes: hjkl goes left, right, up, and down,
but you also have other keystrokes that are more specialized to the application.
You can run the code.
We'll see that happen here in a minute.
You can make changes to it really quickly
and see the effects of those changes.
You're doing this all in a mode
that's convenient for this particular application,
which is editing Lisp code,
and that is, in this case, symex-mode.
Typically, when you're editing code like this,
you'd want to be in insert mode
actually typing out the code,
and then you'd want to escape to symex mode rather than normal mode,
and then you could escape again
and you'd end up in normal mode.
So this, if we go to mode mode, we see is depicted
as this tower where insert is at the
bottom and normal is at the top,
but symex-mode is in between the two.
You could also change that if you like.
If you don't want symex-mode to be there,
you could just move it to the top.
Now you find symex is at the top
and you enter down to normal.
You can see it on the status bar at the bottom there.
Enter to insert, escape to normal, escape to symex.
In fact, you can even add more modes
if you don't like the existing ones.
Now we have an additional mode here.
We have window mode. It goes down to symex,
it goes down to normal.
Enter the insert, escape to normal,
escape to symex, escape to window.
So we've talked... Okay, so another thing actually to note here
is that in editing modes,
if you look at the mode line
at the bottom of the screen,
you'll see that we are currently,
in this buffer,
we are currently in line mode.
I'm going to hit Enter now
and you'll see that when I hit Enter,
nothing is happening.
It's still in line mode.
If you hit Escape, it's still in line mode.
You can find out the reason for that
by taking another meta jump out of this.
You'll see that, in fact, the reason
is that we're currently in line mode,
and line mode is the only one available
in this tower
for editing the modes that are
in operation in your ground level.
In fact, line mode is all you need here,
because this is just the nature of how these modes are laid out is in rows.
So line mode is the most appropriate thing here.
But you could change it to something else if you like.
Now we've seen two towers.
We've seen the Vim tower and we've seen also the symex tower, the Lisp tower.
It turns out that, because we've been talking about towers now,
by the Rumpelstiltskin principle, towers also can be talked about,
and therefore they also are a mode.
So how do we go to tower mode?
The way we go to tower mode is
we go in a slightly different direction,
and we find that we are now in tower mode.
We see that there are many towers available. We're now...
We're seeing several possible towers
that we have written to be available and for use in different buffers.
You can edit them on the fly.
For instance, let's enter this tower.
Now you see that in the bottom of the...
In the mode line, you see that we're
going across all of these different modes
that were in the tower.
You could escape and you could even move things around.
You could put window mode
all the way at the bottom,
right above insert mode.
Let's see that happen. There it is,
window is right above insert, and so on.
The tower always reflects your current position,
so if you're in buffer mode here and you go down to line mode,
when you go back to mode mode, you see that we are in line mode.
But in practice, you wouldn't have a tower this elaborate
because you'd rather have several smaller towers you enter,
that you alternate between.
Okay. So one other thing of interest here is that
when you're in tower mode,
if you look at the status line at the bottom there,
we are currently in buffer mode while we are in tower mode.
Tower mode actually isn't a mode really. Neither is mode mode.
They're really referential planes or meta planes.
In any case, you can see that we're in buffer mode.
We can take a meta jump out of this
to confirm that buffer mode is the only mode available
when we're editing towers
because that's the one we need,
given that our towers are represented in individual buffers.
Right. So let's see where we're at.
Rumpelstiltskin principle...
We talked about mode mode.
We talked about the strange loop
application of ground level modes in meta levels.
We saw the different towers,
and in fact, we're currently in Vim tower,
where you can go to Emacs tower.
Now, with a single keystroke, you can
alternate between Emacs and Vim,
which are represented--
which are modeled as towers.
So there's... One thing
that we've sort of alluded to is that there are two directions
that you can travel in
when you're going through this framework.
One direction is--and we'll visualize it like so...
There's two directions you can travel,
and you can either go sideways or you
can go up and down.
If you go sideways, you're changing your perspective.
So normal mode, word mode, line mode,
window mode, and so on
are all different perspectives on your ground editing experience.
The other direction you can travel in
is up or down, which takes you through meta levels.
So you go from the ground level editing experience,
up to mode mode, and then up to the tower plane, and so on, and so on.
So this all sounds very complex,
but the truth is it's not really that complicated,
even though it feels that way.
The reason it isn't that complicated
is because no matter how many levels
up or down you go and no matter where you are,
whether you're in at the ground level
editing the actual text
or whether you're at a meta level,
some unknown meta level and you don't know where you are,
no matter where you are,
the way in which you interact with it
is the same at every level.
That is the great power of this approach:
that all of the different levels are the same.
In fact, the complexity of the whole
is exactly identical to
the complexity of each part,
so if you know how to edit words
in the ground level buffer
and you know how to move lines around using line mode,
then you know how to edit any aspect of your editing experience at any level.
So this is a pre-release demo.
This doesn't exist on MELPA yet, but you can follow updates at this repo on github.
If you can also be a beta tester
or something like that, if you like, that would be very helpful.
You can learn more about this at
drym.org, which is where I house
the research that I work on.
In particular, the research on epistemic levels
is what inspired this particular Emacs extension.
You can also learn about
dialectical inheritance attribution, which is the basis of
a new economic system that could be fair
and could lead to a prosperous and happy world.
You can follow me on Twitter at @countvajhula.
That's it! Thank you.