2024-07-24 My ed, wondering
===========================

Sometimes I have the urge to write a small editor, something like the
kilo project: so small that it is barely usable. I also imagine it to
have a sort of conversational UI – which I guess ed has? – if ed is
your grumpiest of companions! – or maybe the M-x commands for emacs –
and I guess I‘m looking at Oddµ as a site generator and Markdown file
server and I wonder: what sort of editor would I need to maintain
this? What sort of minimal SVG editing capabilities would be nice to
have?

What if I could use an ed-like "conversational" interface, with better
prompts, wrapped in readline for ‹Up, Return› combos to repeat
things, opening multiple files, switching between them, with
completion or menus, and saving it all in one go.

I think I will install rlwrap as a first step and wrap ed and mail
in it.

When I read the Wikipedia pages of sam and acme I get the feeling
that the started out at the same point and then moved towards a
different, full-screen, mouse-support paradigm.

What would my ed have, in addition to ed?

My ed would have the notion of "units". Perhaps these can be defined
by a separator marker, a regular expression. A "line" is a unit
separated by a newline, or a "beginning of line" regular expression. A
"sentence" is a unit separated by all sorts of punctuation followed by
zero or more quotes and one or more spaces, and so on. A "block" is a
unit separated by empty lines, or special line beginnings such as
header markup or list item markup. A "section" is a unit separated by
line beginnings with header markup. These unit names and the
corresponding separators are defined in a file, per type, so that they
can be changed.

File types are associated with file extensions or special matches
(such as looking at the first two lines of a file).

My ed would have a config file so that it can be redefined in parts.
For example, every file type has special, system dependent commands to
"render" it, be it compilation, viewing, printing, etc. Perhaps
mailcap could be an interesting option to fall back to.

My ed would be line oriented and still offer keyboard navigation using
the arrows or vi-style keys. It would have two panes: the top one
would show the file content and a cursor or the highlighted unit. The
bottom one would be a command line history. The command line history
shouldn't be a complete file buffer that can be edited, though,
because the temporal ordering seems important to me.

The navigation commands can also be used to modify the selection.
Ideally, using arrows to move, shift arrows to select, and typing
commands would all work seamlessly.

My ed would have commands that are words or even phrases, and can
defined more of them in files, and edit and "source" them into your
session. It would have understandable errors.

My ed would have a snarf buffer or a clipboard to use for cut, copy
and insert. Cutting and copying would work on whole units.

My ed would have infinite undo and redo and an auto-save file. Perhaps
the auto-save file would contain the redo script.

I'm starting to wonder whether I'm reinventing vi, here. 🤔

​#Editors