The Kalem Book GitHub

This Book describes Kalem's main branch, which may be ahead of the latest release.

Kalem and Emacs

Kalem takes more from Emacs than from any other editor, and leaves out the one thing that makes Emacs what it is. This page says which is which and why, so that the first question an Emacs user asks has its answer written down.

1. The short answer

Kalem has Emacs's architecture: every action is a command, keymaps are data, each kind of text has its mode, the same editor runs in a window and in a terminal, and every operation runs in batch. It has Emacs's best applications: Org, Dired, Projectile, and the agenda and Babel on the way. It does not have Emacs's defining property: a live Lisp runtime in which the user reprograms the editor while it runs. Kalem is not a modern Emacs and does not call itself one. It is an editor for people who want what Emacs does for text files and do not want to program their editor.

2. What Kalem takes from Emacs

In Emacs In Kalem Where
Every action is an interactive command; keymaps are data; describe-key A command registry; kalem commands lists every command with its ID, scope and keys; the palette finds commands by ID; keys in keymap.json; a which-key panel after a prefix Keys, Finding and commands
A major mode for each kind of text A document mode for each format, on one contract; a plugin's mode uses the same contract as the built-in ones Part II, Part III
Org mode Org as Emacs reads, edits and exports it, checked against Emacs construct by construct Org, Known differences
Dired and wdired The file manager: marks, operations in the background, names edited in place with e, Doom's Dired keys The file manager
Projectile Projects, their files with ignore rules, find in files Documents and projects
emacs -nw The terminal editor, with the same commands, keys, settings and views, never second class (decision D26) Terminal parity
emacs --batch The command-line tools (check, fmt, export, query, table); kalem run for a plugin's command The command line
Narrowing, outline, folding, org-indent-mode The same, in both editors Views
Evil and Doom's leader map The Vim profile with Doom's leader; every Doom key listed with what it does or why not yet Keys
The agenda, capture, clocking, Babel Planned (docs/todo.md, groups 15 and 16)  
Org's keys (C-c C-t, C-c C-s, =M-RET=…) An example keymap to copy from, docs/keymaps/emacs.json Keys

3. What Kalem leaves out, on purpose

In Emacs In Kalem Why Decision
Elisp: the editor is a Lisp machine; any function can be redefined or advised while it runs No scripting language, no REPL, no eval. Plugins are compiled Rust, run as WebAssembly components on a typed API, with only the capabilities they were granted A plugin cannot read what it was not given; no interpreter to start or to keep fast; one language for the core and the plugins. The price is in the next section D10, D28
init.el: configuration is a program settings.toml and keymap.json: data that Kalem checks when it reads it and reports, value by value A wrong line cannot break startup; configuration is diffable and portable; nothing to learn before the first key is changed D9
Everything is a buffer: Dired, the agenda, a shell, mail are text buffers with a mode Documents, grids, listings and panels are views of a shared model; a grid is a grid, a listing a listing, and the terminal editor shows the same views A table edited as a grid and a CSV as a spreadsheet read better than a text buffer, and the terminal can draw them; the editor stays an editor of files §4.1, principle 7
Hundreds of variables for Org, the agenda and export The document's own keywords (#+STARTUP, #+OPTIONS, #+TODO=…) and a short settings file; the defaults of =emacs -Q are Kalem's defaults A file reads the same in both programs; Emacs with no configuration is the reference Kalem is tested against Part II
Packages from ELPA and MELPA, with full access to the editor and the machine Plugins from a registry: signed, sandboxed, their permissions shown at install, their time and memory limited The reader of a shared document should not run what its author's plugins run D28, §11.6
Packages that extend Org's syntax Standard formats are never extended: Kalem writes nothing into a file that its format does not define A co-author in Emacs never meets a line only Kalem understands TS.14, RFC 0002

4. What that costs

An Emacs user will miss three things, and Kalem does not pretend otherwise.

  • Trying a thing in a minute. M-: and eval let you change the editor without leaving it. Kalem has nothing at that speed. What it has: keymap.json binds any command with arguments to any key; kalem commands and the palette show every command; keyboard macros are being added (T3.7b.8); an inspection panel that answers "what did this key run, and where did this setting come from" is planned (T3.2.1). Anything beyond that is a plugin: kalem plugin new, Rust, a build.
  • Advice and redefinition. Changing how a built-in command behaves. A command in Kalem has settings and a scope; a plugin can register a command on the same key with a narrower scope and take it over; it cannot change a built-in command's body.
  • The buffer as the universal interface. A shell, mail or chat inside the editor. Kalem does not try: it edits files, and its terminal editor lives inside your terminal rather than the other way round.

What the same user gains: a start in a fraction of a second, a document that looks like a document with its formulas drawn, the same editor over SSH with images where the terminal draws them, a grid for tables and CSV, and a file that Emacs reads back with a diff only where it was edited.

5. Working beside Emacs

An Org file edited in Kalem returns to Emacs changed only where you edited it: tables aligned as org-table-align aligns them, tags at the column the file uses, blank lines and indentation as the file has them, and no keyword Emacs does not know. Emacs is the reference: kalem diff-emacs compares every construct of a file with org-element, the editing commands and the exporters are compared the same way, and the deliberate differences are listed in Known differences from Emacs Org, each one a test.

For hands that know Emacs: docs/keymaps/emacs.json has Org's keys to copy from, the Vim profile has Doom's leader, and the Doom leader table in Keys lists every Doom key with what it does in Kalem or why it does not yet. The file manager's keys are Doom's Dired keys.

6. Is Kalem a "modern Emacs"?

By architecture, yes; by essence, no. The phrase promises a malleability Kalem chose not to offer, and it starts an argument about what Emacs is instead of a conversation about files. Kalem says instead: Emacs's ways, without Emacs. The commands, the modes, the keys and the applications, for people who do not want to program their editor. For those who do, Emacs remains the better tool, and Kalem keeps their files byte for byte.