Acme in 2026

By Connor Taffe | Published .

A few years ago, I discovered Acme. All through my adventure into programming, I've appreciated the history — the narratives we use to teach each successive generation of programmers about the past, and the characters who star in those stories. Ken Thompson and Dennis Ritchie star in the UNIX story, and Bell Labs, after all its contributions to the world from the transistor to the laser, is known to me foremost for UNIX, the operating system whose descendants I use every day. The story I learned ended with UNIX, but the real story went on for decades, and those individuals and their colleagues went on to iterate on their designs. For reasons beyond their control, those creations did not proliferate as UNIX did.

Looking at it now, after years working with Linux, Kubernetes, and containers, Plan 9 seems like a utopian vision for computing — where complexities like networking and scaling across machines are folded into the simple ideas that underlie the entire operating system: the 9P network filesystem protocol, and per-process namespaces. From this place we may visit but cannot stay comes the Acme editor. It seems frozen in time much like the UNIX editors, but a different time — a time with bitblit terminals and graphical window systems. Acme greets you with yellow boxes, blue trim, proportional fonts, and text. Everything is text, and editable, and interactive through a three-button mouse. To explore it is to experience a new way of interacting with your computer: the excitement of seeing the UNIX commands you've used for years in a terminal, limited by its line-editing ability, spring to life in an incredibly mutable environment — sending editor text through |sort with a click, editing the scrollback buffer in the win terminal — simple but powerful.

I decided to try Acme as my primary editor over a year ago. It felt like writing left-handed. I was slow, the keyboard shortcuts I had memorized didn't work, I had no way to navigate across source code, the commands I used didn't work with win's TERM=dumb — dotting ugly escape sequences and gushing lines ending in \r — I couldn't remember the mouse chords. Eventually I found my bearings: I set Iosevka Mono 12 as the default font, set up acme-lsp and dug up working configurations for a handful of LSPs, I wrote acme-search so I could have a live search window like ⌘P gave me in VS Code, I added up and down arrow navigation to Acme (sacrilegious to proportional font users) and hacked in shortcuts like ⌘S and ⌘B. I extended acme-lsp to support workspace symbol search and running a language server's own commands from scripts and plumbing rules, and even extended metals so I could plumb JVM stack traces with the same right-click I could Go's. In finding my way, I bent the editor to me, but I don't think it's the best way or the right way, it's just my way — and that's one of the things Acme is meant to do, allow you to build your way, with your own tools, through it.

Acme running on macOS showing syntax-highlighted C and Go source files alongside a terminal window querying the acme-styles 9P compositor filesystem for window 20
Acme running on macOS showing syntax-highlighted C and Go source files alongside a terminal window querying the acme-styles 9P compositor filesystem for window 20

Above is Acme in color for the first time, driven by programs outside it through its file interface, in a way that aligns with Acme's design philosophy. The beauty of Acme in part lies in its careful omission; I have strived to add little to Acme itself, only the minimal interfaces needed to build everything else outside it.

This post is broken down into several sections:

What is Acme?

Acme is a tiling window manager and a text editor in one, the screen is divided into columns, then each column is divided into windows. A window has two parts: its tag, the line of text across the top (the blue bar in the screenshot above), and its body, the text on pale yellow below. The tag holds the file's name followed by words like Put, Get, Undo and Del. These are commands, and so is any other text: you can type mk or |sort into a tag, or anywhere in a body, and run it.

Acme is mouse-driven, and supports chords reminiscent of the kind Douglas Engelbart showed in his 1968 "Mother of All Demos". Left click (Button 1) selects text. Middle click (Button 2) executes the text under it as a command: Put saves the file, Del closes the window, and any other command falls through to the shell, run in the window's directory. Right click (Button 3) plumbs the text: a file name, or file:line, opens in a window, other text goes to whichever program the plumber's rules choose, and anything else is searched for in the window.

Each window is also presented as a directory of files. body is its text, tag its tag, addr and data let a program read or replace a range, and event streams clicks or edits. The beauty in this interface is that any program that can read and write files can control Acme. In this post I have examples of Go and rc shell programs.

Acme is Rob Pike's text editor, described in a 1994 USENIX paper1 and included in Plan 9. I use it through plan9port, a port of the Plan 9 userland to UNIX maintained by Russ Cox. His video tour is the best introduction:

Russ Cox uses the phrase "integrating development environment"2 to describe the way Acme integrates command-line tools.3 Select text and middle-click |sort to replace the selection with sorted output (a filter). Middle-click |wc -l to replace it with a line count. Middle-click <date to insert its output at the cursor, replacing any selection (a source). Middle-click >mail user@host with selected text to send it (a sink). Middle-click mk to build the project in a new errors window. Acme draws no distinction between these — they are all commands executed with the window's directory as context and the selection as input.

The paper calls Acme "a hybrid of window system, shell, and editor."

Acme is in part a file server that exports device-like files that may be manipulated to access and control the contents of its windows.

Each window exposes a directory of 9P files — the body is {w}/body, events flow through {w}/event. External programs read and write window content through the filesystem, and the design anticipates multiple external programs writing to the same window simultaneously:

Any number of agents — the keyboard, mouse, external programs writing to data or body, and so on — may change the contents of a window.

Pike states in the paper that Acme "applies some of the ideas distilled by Oberon."4 The tiled columns, the three-button mouse, and the idea that any visible text can be a command are ideas shared by Wirth and Gutknecht's Oberon system. The difference is the interface: where Oberon uses objects and modules within a programming language, Acme uses files and commands within the Plan 9 operating system.

In Plan 9,5 many services provide a 9P file server,6 and each process has its own namespace — its own view of the filesystem, assembled by binding and mounting.7

On Plan 9, Acme mounts its file server into its own namespace and each command's; plan9port serves it as a socket at $NAMESPACE/acme. Any process that mounts it can read window bodies, write events, and open new windows through ordinary file operations. The services described in this post are 9P servers composed the same way.

Pike noted in a 2009 thread that he had always intended for Acme to support more than plain text.8

plan9port9 brings Acme to macOS via devdraw (a Cocoa rendering backend) and fontsrv (Core Text fonts served as a 9P file server). The editor itself is unchanged from the 1994 design. What has changed is the ecosystem around it.

Many people have written about their experience with Acme.1011121314151617181920212223

Namespaces

The power of per-process namespaces goes beyond editors. On Plan 9, $path is just /bin — you add commands by union-mounting24 directories over it instead of maintaining a colon-separated search path. The profile Plan 9's newuser25 writes for each user begins:

bind -a $home/bin/rc /bin
bind -a $home/bin/$cputype /bin
bind -c tmp /tmp

Your own scripts and binaries are unioned after the system's in /bin, and your private tmp replaces /tmp.

Networking works the same way: interfaces live under /net/ipifc and routes under /net/iproute.26 Because /net is just files, a process can mount an entirely different /net into its own namespace, transparently rerouting all its network access. The import command mounts a remote machine's files into your local namespace, and cpu exports the local namespace to a remote machine for execution.27 Acme windows on a remote machine are accessible the same way they are locally.

Pike's concurrent window system in Newsqueak,28 a language whose channels later influenced Go, gave each client its window as a bitmap to draw on, and its keyboard and mouse as channels: K: chan of int, M: chan of Mouse. Since the window system utilizes the same interface, it can run within itself recursively. Its successor 8½29 turned the channels into files: each window has its own /dev/cons, /dev/mouse, and /dev/bitblt, served by 8½ atop those provided by the Plan 9 kernel. The Third Edition moved graphics into a shared draw device, which, as rio's manual puts it, "multiplexes itself." rio30 still gives each window its own /dev/cons, /dev/mouse, and /dev/winname, but a program draws on the kernel's /dev/draw directly, on the image winname points to: rio "places windows but does not mediate programs' access to the display device." A rio run inside a window takes that window's image as its screen. This design simplifies the write path and eliminates copies of the draw buffer.

The cpu command31 uses these same files to connect a thin terminal to a remote CPU server. The terminal exports its namespace via exportfs, and the CPU server mounts it at /mnt/term. cpu itself only opens /mnt/term/dev/cons for the shell; the binds are in the user's profile, whose case cpu does the rest:

case cpu
	if (test -e /mnt/term/mnt/wsys) {
		# rio already running
		wsys = /mnt/term^`{cat /mnt/term/env/wsys}
		bind -a /mnt/term/mnt/wsys /dev
		echo -n $sysname > /dev/label
	}
	bind /mnt/term/dev/cons /dev/cons
	bind /mnt/term/dev/consctl /dev/consctl
	bind -a /mnt/term/dev /dev

A CPU server binds no draw device of its own, so /dev/draw there is the terminal's kernel draw device, served over 9P, and /dev/winname and /dev/mouse are rio's. Programs executing on the CPU server read the local keyboard and draw to the local screen without knowing they are remote.

The same idea was incorporated into Linux as mount namespaces, the foundation of containers; Appendix: Plan 9's namespaces in Linux explores that journey.

rc

Plan 9's shell is rc,32 designed by Tom Duff at Bell Labs as a replacement for the Bourne shell.

Rc draws heavily from Steve Bourne's /bin/sh. Any successor of the Bourne shell is bound to suffer in comparison. I have tried to fix its best-acknowledged shortcomings and to simplify things wherever possible, usually by omitting inessential features. Only when irresistibly tempted have I introduced novel ideas.

The most important principle in rc's design is that it's not a macro processor. Input is never scanned more than once by the lexical and syntactic analysis code (except, of course, by the eval command, whose raison d'être is to break the rule).

Bourne shell re-scans variable values when they are substituted into a command, e.g. $x expands to a string that is then word-split on IFS, so a variable containing hello world becomes two arguments. This requires we quote variables anytime we wish they remain one string, and leading to several variants of quoting syntax, and a persistent source of bugs. In rc, variables are lists: $x expands to a list item directly, without re-splitting. The only time text is split is when output is read from a command, e.g. x=`{echo a b c}. This is just one of the many improvements rc makes to the UNIX shell.

plumber

The plumber is Plan 9's inter-application dispatch layer.33 Right-clicking text in any Acme window sends it through a rules file. The rules pattern-match against the text and context — filename, working directory — and decide what to do: open a file in Acme, send a URL to the browser, run a command.

Pike described the plumber in "Plumbing and Other Utilities":

The result is similar to a hypertext system in which all the links are implicit, extracted automatically by examining the data and the user's actions.

Right-clicking a filename opens it. Right-clicking a URL opens the browser. Right-clicking a compiler error opens the source file at the right line. Nothing is explicitly linked; the plumber infers the action from the data.

The plan9port default rules handle the common cases. I've added several custom rules in ~/lib/plumbing. The first line of the file is a comment that doubles as a reload command:

# Edit ,>9p write plumb/rules

Middle-clicking that line in Acme selects the entire file body (,), pipes it through 9p write plumb/rules, and the plumber is updated live.34

Go and Python stack traces already contain file paths — /usr/local/go/src/fmt/print.go:1234 — so the default rules handle them. JVM stack traces need a language server to resolve them; Scripts on the language server has those rules.

win

The win command opens a shell inside an Acme window. The scrollback buffer is the window body, just text: editable, searchable, plumbable. As Russ Cox recounts in the video tour, you can leave yourself notes in your debugger output, delete mistyped commands or noisy output, and edit a command in place before re-running it with a middle-click — a more elegant form of up-arrow and edit in a standard terminal. You can right-click a path in compiler output and the plumber opens the file. You can select text in the output, middle-click |sort, and the selection is replaced with the sorted result. The scrollback responds to the same mouse chords as any other Acme window.

At first you might balk at this user-mutable and program-immutable terminal, but this is actually the original UNIX terminal: the paper teletype. As Kay Lack outlines in The little editor that could, ed (and by extension sam -d) makes more sense if you consider the output goes to a roll of paper you can then mark up.

Working in Acme

Acme is a personal editor; you build the tools you need to extend it. For years, I've curated my own ~/bin of simple commands wrapping curl and jq, or stringing together a couple of longer commands; those habits pay off in Acme, and you can extend them with simple text-based window UIs or plumbing rules.

Plumbing rules

Beyond the defaults, I have rules for git commits, Jira tickets, and GitHub PRs. Right-clicking a commit hash like commit a1b2c3d4 runs git show and plumbs the output into an Acme window. Right-clicking a ticket key like PROJ-1234 opens a Ticket window that fetches the issue from Jira, formats it as Markdown, and handles Get to refresh:

type    is  text
data    matches '[A-Z][A-Z]+-[0-9]+'
plumb   start rc -c 'Ticket '$0

Ticket and PR are simple Acme applications written in rc, using plan9port's acme.rc library to create a window and run an event loop. The body function fetches the ticket, formats it to the window width, and writes it to the body through the filesystem interface:

#!/usr/bin/env rc
. $PLAN9/lib/acme.rc

key=$1

fn body {
    ctl=`{winread ctl}
    pixels=$ctl(6)
    tabpx=$ctl(8)
    cols=`{echo $pixels $tabpx $ts | awk '{printf "%d\n", $1 / ($2 / $3)}'}

    echo -n '0,$' | winwrite addr
    jira read $key | mdnorm | mdfmt -w $cols | winwrite data
    winctl clean
}

fn event {
    switch($1$2){
    case Mx MX
        switch ($9) {
        case Get
            body &
        case Del
            windel sure
        case *
            winwriteevent $*
        }
    case Ml ML
        winwriteevent $*
    }
}

newwindow
winname $home'/+jira/'$key
echo -n 'Get' | winwrite tag
body &
wineventloop

jira read fetches the issue from the Jira REST API and converts the Atlassian Document Format body to Markdown, including status, links, children, and comments. mdnorm normalizes the Markdown and mdfmt word-wraps it to the window's column width. Right-clicking org/repo#123 opens a similar PR window with the description, review comments, and diff fetched from gh.

I've found that identifying a one-word plumbable format like org/repo#123 for PRs works the best; using this format as input and output in any commands you write then adds further value.

Taming win

win sets TERM=dumb, so commands that emit escape sequences need to be tamed. In ~/lib/profile (rc's equivalent of .profile) I set:

NO_COLOR=1
PAGER=p
EDITOR=E
GIT_QUIET=1
BUILDKIT_PROGRESS=plain
MAVEN_ARGS='--batch-mode -Dorg.slf4j.simpleLogger.defaultLogLevel=warn'

NO_COLOR35 disables color output in tools that respect the convention. p is a plan9port pager that works without terminal control sequences. E opens files in Acme. GIT_QUIET suppresses the progress bars that produce streams of \r in win. The Maven and Docker flags do the same for their respective build output.

How it fits together

Each piece of this stack is a separate program that talks to Acme, and to the others, through 9P files. Styling information is provided asynchronously by tree-sitter and the gopls and clangd language servers via acme-treesitter and our fork of acme-lsp, and composited by acme-styles. The 9P interface of Acme provides the live document change feed, optimistic locking mechanism, and sink for styled spans through three new but simple per-window files. Each of these components provides a 9P interface of its own, for instance acme-styles adds the concept of a layer, but otherwise presents the same per-window interface as Acme within each layer, allowing programs to work with or without it.

tsacme-treesitterstylesacme-styles ts->styles {w}/layers/{l}/style lsp acme-lsp lsp->styles {w}/layers/{l}/style hl acme-highlight hl->styles {w}/layers/{l}/style acme acme styles->acme {w}/style

9init starts at login, starts fontsrv and plumber, then watches for $NAMESPACE/acme. When I run a, Acme posts its socket and 9init's kqueue watcher fires. acme-styles, acme-hotkey, and acme-focused start concurrently. Once acme-styles posts its own socket, acme-lsp, acme-treesitter, and acme-highlight start. The whole stack is running within a second of opening the editor.

When I open a .go file, acme-treesitter parses it with tree-sitter and writes syntax spans to the compositor. acme-lsp sends the body to gopls and writes semantic tokens to a higher-priority layer. acme-styles composes both layers and writes the result to {w}/style. Acme repaints. When I press ⌘S, acme-hotkey's rule writes put to the focused window's ctl, acme-lsp runs source.organizeImports and formats, and acme-treesitter sees the body change in {w}/log and re-parses. ⌘B opens the definition for the symbol under the cursor in a new window. When I highlight a phrase and press ⌘⇧H, acme-highlight stores the text with its surrounding context. After a Get, the anchor re-resolves at the new position.

Hotkeys

I could not live without the keyboard shortcuts I had built muscle memory for over years in TextMate, Sublime, Atom, VS Code, and IntelliJ. Especially ⌘S to save and ⌘B to go to definition. Acme on macOS has only a handful of built-in shortcuts — cut, copy, paste, undo. The keyboard-centric shortcut model is exactly what Acme is trying to move away from. But ⌘S is not optional for me.

acme-hotkey isn't limited to single chords. Its rules are patterns over keys, so a binding can be a sequence, as Emacs's C-x C-s is, can wait for a pause before it fires, and can switch the rules into a mode until another key leaves it. Rules as automata shows how.

acme-hotkey handles keyboard shortcuts at the macOS session layer via a CGEventTap.36 The tap intercepts keystrokes before they reach any application. Key names are derived from the active keyboard layout via UCKeyTranslate, so the same physical key always produces the same logical name regardless of input method state.

The tap hands each keystroke, and the process it is headed for, to the daemon, which steps its rules and answers consume or pass before the tap's callback returns. A key no rule wants is the original event, passed on untouched, so the system and the application see it as if acme-hotkey were not there. System shortcuts such as Spotlight and screenshots always pass through. A key a rule wants is consumed, and the rule's rc script runs.

The rules live in ~/lib/hotkeys, in the manner of the plumber's rules, and the service serves them as files:

acme-hotkey/
  rules    read: the rules; write: replace them
  card     read: every binding, one per line: scope, keys, action, label
  send     write: "app key" lines, matched as if the key were pressed

As with plumb/rules, a write to rules is checked as it arrives, so an error comes back on the write with its line number, and nothing is installed until the rules are sound. The first line of the file reloads it with a middle-click, as my plumbing file does.

My rules, nearly whole:

# Edit ,>9p write acme-hotkey/rules
%{
fn focus { 9p read acme-focused/focus }

fn ctl { echo $1 | 9p write acme/`{focus}/ctl }

fn in {
	id=`{focus}
	dir=`{9p read acme/$id/tag | awk '{print $1}'}
	if(! test -d $dir) dir=`{dirname $dir}
	cd $dir
	winid=$id $*
}

fn putall {
	for(id in `{9p read acme/index | awk '$4 == 0 && $5 == 1 {print $1}'})
		echo put | 9p write acme/$id/ctl
}
%}

main:
	-> acme when app == "devdraw"

acme:
	command-s		{ ctl put }	# save
	command-shift-s		{ putall }	# save all
	command-w		{ ctl del }	# close the window
	command-t		{ in win }	# terminal
	command-b		{ in Ldef }	# definition
	command-shift-b		{ in Lrefs }	# references
	command-p		{ in Search }	# search
	command-shift-h		{ in Highlight }	# highlight

The prelude between %{ and %} is prepended to every rule's block, and each block runs in its own rc. ctl writes to the focused window's ctl file;37 in runs a command as if it had been middle-clicked in the focused window, in its directory and with $winid set. The main scope reads in the acme scope's rules only while the key is headed for devdraw, the process that draws plan9port's windows, so ⌘S still saves in every other application.

Rules as automata

The rules language is the hotkey dialect of seq, from my automaton library of small languages compiled to tables. A pattern is an expression over keys, as in a lexer: keys in sequence, | between alternatives, groups, and *, + or ? after a key or group. A line name: starts a scope, and -> scope after a rule moves to that scope until another rule leaves it, so modes fall out of the same mechanism as chords. An emacs-style C-x C-s is two keys in sequence:

%delay settle 1s

acme:
	control-x control-s	{ ctl put }
	control-x settle	{ ctl show }
	control-x / any		{ ctl show }
	command-g		{ ctl nomark } -> group

group:
	-> acme
	escape			{ ctl mark } -> main

Time is a symbol, an approach taken from reverse engineering an Elcotel Series 5 telephone and writing a dialer automaton. %delay settle 1s declares a delay, and settle in a pattern is read when the machine has waited that long, so control-x settle fires once a second passes with nothing after control-x. any reads a key no other rule names at that point, and / ends a pattern with a key it reads without taking, so control-x / any fires at once and lets the next key do what it would have done.

The rules compile to one table, and conflicts are errors at compile time: two rules on the same keys, or a rule that is the start of a longer one without a delay to tell them apart. A key is taken only when a rule that holds can use it, which is what lets every other key pass through untouched.

My first version was a pipeline: acme-hotkey served keystrokes as lines of text, and a script in straw, my attempt at the AWK that Pike's Structural Regular Expressions describes, matched them and wrote the unmatched ones back. The tap held every key until the pipeline judged it, and re-posted the ones it passed straight to the application, so the system never saw them: Space after ⌘⇧4 went to Acme instead of the screenshot overlay. Matching the rules in the daemon while the tap waits means a key no rule wants is never held or re-posted at all.

acme-focused watches acme/log for focus events and exposes the current focused window ID as a readable file at $NAMESPACE/acme-focused/focus. The rules' focus function reads it; without it, a shortcut has no way to find the window it is meant for.

Syntax Highlighting

Syntax highlighting is a contentious subject in the Acme community. In 2008, someone on the 9fans mailing list posted a list of nineteen feature requests for Acme.38 Russ Cox responded to each with the "Acme way" of working:

A former classmate recounted his reply when asked why he didn't use syntax highlighting himself: "Do you color code all your English by part of speech?"39

There is something to this. Nikita Prokopov's (tonsky) essay on syntax highlighting40 makes the point well — most color themes assign unique bright colors to everything, the eye adapts, and the highlighting loses its informational value. His prescription is so few colors that you can hold the entire scheme in memory.

Two years earlier, in a 2006 Inferno mailing list thread, Cox noted:41

However, syntax highlighting is undeniably useful for distinguishing three different classes of text that can easily be confused for each other: regular program, comments, and string literals.

He went on to note that Acme and libframe were not structured to handle different colors for individual pieces of text, but:

It would be nice in some contexts if acme could assign fonts and perhaps colors to the text it displays... And yes, you might even do something like syntax highlighting, again as a separate acme client program.

I use colors to distinguish the few semantic classes that matter: keywords, types, strings, and comments. The palette names each class a highlighter can report — keyword, string, comment, and so on. You choose which ones to use by which colors you assign them. Comment most of them out and only the classes you care about become visible.

Acme on macOS with five windows in two columns, colored by tree-sitter and gopls through acme-styles: a goyacc grammar whose rules carry Go actions colored as Go; a Markdown README with one sentence highlighted in yellow and a fenced Go block colored as Go; an acme-lsp TOML configuration with its comments and strings colored; a Go source file with semantic colors from gopls; and a directory listing
Acme on macOS with five windows in two columns, colored by tree-sitter and gopls through acme-styles: a goyacc grammar whose rules carry Go actions colored as Go; a Markdown README with one sentence highlighted in yellow and a fenced Go block colored as Go; an acme-lsp TOML configuration with its comments and strings colored; a Go source file with semantic colors from gopls; and a directory listing

The Design

I added three files to each Acme window in my plan9port fork (cptaffe/plan9port), instead of building syntax highlighting into the editor:

File Description
{w}/style Accepts styled spans — a palette of named colors (:name fg=#rrggbb bg=#rrggbb) followed by a run list of rune-offset ranges (start len name).42 Writing to {w}/style changes how Acme paints the window.
{w}/log Streams body edit events to any number of concurrent readers without write-backs. Each entry follows the event file format: I 42 47 0 5 hello\n (op, q0, q1, flag, nr, text). Before {w}/log, acme-lsp tracked edits by polling {w}/body on a timer.
{w}/seq A counter that increments with every body edit. Writing a number to {w}/seq arms a guard, which the next open of {w}/body, {w}/data, {w}/xdata, {w}/style or {w}/log takes. Every read and write on that file then fails with seq mismatch if the body has been edited since, and style runs written under a stale guard are dropped when the file closes. As writing {w}/addr scopes a write to {w}/data, writing {w}/seq scopes the file opened next to one version of the body — the client can never write stale spans.

These three files alone are enough to implement a simple highlighter as a shell script. This one watches acme/log for .foo files and highlights comments (#) and strings ("...") using rc and awk:

#!/usr/bin/env rc

fn highlight {
	id=$1
	{
		echo ':comment fg=#336633'
		echo ':string fg=#880000'
		9p read acme/$id/body | awk '
		BEGIN { pos = 0 }
		{
			n = length($0); i = 1
			while (i <= n) {
				c = substr($0, i, 1)
				if (c == "#") {
					printf "%d %d comment\n", pos + i - 1, n - i + 1; break
				}
				if (c == "\"") {
					j = i + 1
					while (j <= n && substr($0, j, 1) != "\"") j++
					if (j <= n) j++
					printf "%d %d string\n", pos + i - 1, j - i
					i = j; continue
				}
				i++
			}
			pos += n + 1
		}'
	} | 9p write acme/$id/style
}

9p read acme/log | awk '{print $1, $2, $3}' | while(id op name = `{read}) {
	if(~ $op new put && echo $name | grep -qs '\.foo$')
		highlight $id &
}

The script reads the window body, walks each line character by character to find # comments and "..." strings, emits rune-offset runs, and writes the palette and runs to {w}/style in one pipe. This is roughly the regular-expression highlighter Cox described in 2006, written as a client of the files rather than inside Acme.

acme-styles

Multiple tools need to write {w}/style simultaneously. Acme's {w}/event file enforces a single consumer through a write-back pipeline, but {w}/style has no such mechanism. If tree-sitter, the language server, and the Highlight tool each wrote directly, the last write would overwrite the others.

acme-styles is a 9P file server that sits between highlighting tools and Acme. Its watch package tracks window lifecycles, built on the acme package of our 9fans-go fork (cptaffe/9fans-go, forked from 9fans/go). Each tool writes spans to a named layer. The compositor merges all layers by priority order and writes the result to {w}/style.

acme-styles/
  20/
    layers/
      new        read to allocate a layer; returns its number
      index      read to list the window's layers
      3/
        name     the layer's name, as treesitter or lsp
        addr     write to scope the next style write to a range
        style    write the layer's spans
        seq      write a seq to guard the next style write
        ctl      write "del" to remove the layer
    style        read the composed output

Layer priority comes from the master palette file (~/lib/acme/styles):

@ highlight
@ *
@ lsp
@ treesitter

@ lines define stacking order. * catches unlisted layers. A manual highlight (yellow) always wins; LSP semantic colors override treesitter syntax colors where they overlap; treesitter fills the rest.

Palette entries define named colors:

:base      fg=#000000 bg=#FFFFF0
:comment   fg=#336633 bg=#F0FFF0
:keyword   fg=#00007F bg=#F0F0FF
:string    fg=#880000 bg=#FFF0F0
:type      fg=#440088 bg=#F5F0FF
:highlight fg=#000000 bg=#FFFF00

The names are the same ones acme-treesitter, acme-lsp, and Highlight emit, so a tool needs no table of its own to know what a run means.

The composition algorithm is a sweep line. Each layer's runs are expanded into start/end events, sorted by position with ends before starts. A map tracks which style is active at each layer. At each position, the highest-priority active style wins completely — no attribute merging. When a high-priority span ends, the next layer down takes over immediately. The compositor diffs the result against the previous output and writes only the changed region to {w}/style.

The wire format is the style format I added to plan9port. Palette definitions are :name lines with an optional foreground and background (fg=#rrggbb, bg=#rrggbb). Run entries are start len name — rune offset, rune length, palette name. A composed output for a small file might look like:

:base fg=#000000 bg=#FFFFF0
:keyword fg=#00007F bg=#F0F0FF
:string fg=#880000 bg=#FFF0F0
:comment fg=#336633 bg=#F0FFF0
0 7 keyword
8 14 string
30 42 comment

Gaps between runs default to :base.

The diagram in How it fits together shows the layers flowing in from each tool and the composed result flowing out to Acme.

Tree-sitter

Tree-sitter is a parser generator and incremental parsing library. It builds concrete syntax trees from source files and updates them efficiently as text changes. After an edit, tree-sitter re-parses only the affected region and propagates the change upward through the tree.

Grammars are written in a small DSL and compiled to C. They define which node types produce named captures: @keyword, @comment, @type.builtin, etc. acme-treesitter maps these capture names to palette entries via a lookup table:

keyword   keyword
comment   comment
string    string
type      type
operator  punctuation
operator  string.escape
heading1  markup.heading.1

The lookup is hierarchical: @function.method tries function.method first, then falls back to function. This keeps the mapping small — one entry covers all dot-separated variants of a capture group.

acme-treesitter watches {w}/log for window open and body-change events. When the body changes, it schedules a re-parse (debounced). Since parse and span write are asynchronous, the editor is never blocked on the highlighter.

Language injection handles composite files: fenced code blocks in Markdown are parsed by the inner language's grammar; Go inside yacc grammar files; each injection is an independent parse.

Semantic Highlighting

Our fork of acme-lsp, described under Language Servers, adds semantic token support. Language servers produce type information that goes beyond syntax: gopls distinguishes a type parameter from a local variable; clangd marks namespace qualifiers differently from type names. These come from the LSP textDocument/semanticTokens/full/delta endpoint, which sends changes from the previous state rather than a full token list each time. The resulting spans land in the "lsp" layer, above treesitter in priority. acme-lsp watches the per-window edit log and refreshes incrementally as you type, so semantic colors update without requiring a save.

{w}/seq

Highlighting requires reading the body, running a parse or LSP round-trip, and writing style spans back. If the body is edited during the round-trip, the span offsets will have shifted. There are a few ways to address this: one is to use a regex-based engine to highlight right in Acme as Cox proposed; another would be to use span markers similar to the URL Fragment Text Directives used to highlight text on a linked page. To support a pluggable highlighter, I added a {w}/seq file which functions as an optimistic lock. When read, the file reports a sequence number, which is incremented once per edit. When written, it works similarly to addr, qualifying the next open on a file like data or style.

Each client reads seq, writes seq, opens log, and increments its seq copy once per entry — the read/write dance ensures its seq matched log at open. Before writing spans, it writes seq again, then opens {w}/style. If the body has been edited since that seq, Acme drops the spans when the file closes, and the tool tries again once it has read the outstanding log entries. The guard works from the shell as well: echo -n 42 >seq; cat body reads the body only while it is still at edit 42. A guarded write to {w}/data moves its own guard past its own edit, so a tool can make several edits in a row, each a compare-and-swap against the last.

readread bodyread seqparse parse read->parse check check seq parse->check write write spans check->write match discard discard check->discard mismatch discard->read

A caveat for anyone building on these files: there is a race inherent to these two-file operations. Whenever two processes both attempt to sequence a write to addr then an open of data, or a write to seq and an open of style (which commonly also writes addr to scope the style overwrite), the qualifier can go to the wrong process.

cluster_lspacme-lspcluster_stylesacme-stylesa1write addr#120,#180addr{w}/addra1->addr 1 a2 write data formatted text a2->addr 3: replaces #0,#40 b1 write addr #0,#40 b1->addr 2

The crux of the issue is that Acme keeps addr and seq on the window, global to all clients. There are a couple of ways to address this. One is to put the operations into a single stream such that they are independently ordered, such as an edit file which takes commands and edits inline — sort of an extended ctl; another is a directory per client, such as the layers approach that acme-styles uses for multiplexing; yet another is to use a separate 9P attach (mount) per client, such as Rio does with newwindow.

On Plan 9, Acme does mount itself anew for each command it runs, so each command already has an attach of its own. Programs that share a mount, such as everything started from one win, share its attach, and the kernel multiplexes them over one connection, so the 9P server cannot tell them apart. These sidecars aren't run per-window, but each could mount Acme anew. In plan9port, each connection to the socket attaches on its own, too. There is a problem with this approach, though: Plan 9's exportfs multiplexes any remote clients onto a single attach, and a program Acme didn't start has nothing to mount, since Acme posts no file server in /srv; the /srv/acme.$user.$pid it posts is its errors file.

Inside Acme and libframe

As Russ noted twenty years ago, the highlighting work required changes to both Acme and libframe.

In Acme, I added {w}/style, {w}/log, and {w}/seq along with parsing code in style.c and the per-window edit log in logf.c. The style parser handles both full replacement and partial updates: writing to {w}/style after setting {w}/addr replaces only the runs in the addressed range, leaving the rest intact. I also stripped out my keytab hack so that all keyboard shortcuts are handled externally by acme-hotkey.

Acme stores styled spans in each window as a palette and a sorted array of runs:

struct WinStyleEntry {
    char  *name;       /* "base" for index 0 */
    ulong  fg, bg;     /* RGBA (0xRRGGBBFF), or Nocolor if unset */
};

struct WinStyleRun {
    ulong start;       /* file-absolute rune offset */
    ulong len;         /* rune count */
    int   paletteidx;  /* index into Window.wpalette */
};

Runs are file-absolute, non-overlapping; gaps implicitly use palette index 0 (base).

libframe is the library that renders text into a rectangular region of the screen. It breaks text into a flat array of boxes — each box is a contiguous run of runes that can be measured and drawn in one call, or a break character (newline, tab). The Frame structure holds the box array, the selection range (p0, p1), and the font and color images. Drawing proceeds by walking boxes left to right, advancing a pixel cursor.

To support styling, I added a run-length encoding to the Frame:

struct Frame {
    /* ... existing fields ... */
    int    nstylecols;  /* palette size (0 = unstyled) */
    Image **stylecols;  /* nstylecols * NCOL image pointers */
    int    nstyles;     /* number of RLE segments */
    ulong *styles;      /* {style_index, length, ...} */
};

The styles array is a parallel structure to the boxes: it encodes which palette entry applies to each rune position, compressed as (index, length) pairs. frstyleinsert and frstyledelete keep this array in sync with text edits by splitting and shifting runs.

The drawing function drawrange_impl walks boxes and style segments in lockstep. At each step it computes the next sub-span bounded by the box edge, the style segment edge, and the selection boundary, draws it with the correct colors, and advances both cursors. Each box and segment is visited exactly once — O(n+m) where n is the number of boxes and m the number of style segments in the visible range.

Persistent Highlights

Tree-sitter and LSP highlights disappear when you run Get (Acme's reload command). The highlights are keyed to rune offsets; after a reload the body is new and the offsets are wrong.

acme-highlight solves this with an anchor model adapted from the W3C Text Fragment URL specification, the text fragment directives above. Instead of a rune offset, an anchor stores the highlighted text plus surrounding context — prefix and suffix. After Get, the anchor re-resolves: it searches the new body for prefix+text+suffix. During editing, anchors track position by consuming the per-window edit log and adjusting offsets as usual.

The anchors live in a daemon, acme-highlight, which posts its own 9P service and writes to the "highlight" layer of acme-styles, which sits at the top of the priority stack. The Highlight command (bound to ⌘⇧H) toggles an anchor over the current selection: it writes the selection to the daemon's {w}/addr and then toggles through its {w}/highlight:

acme-highlight/
  20/
    addr        write "q0 q1" to scope the next open of highlight
    highlight   the window's anchors; open for writing after addr to toggle one

I use it primarily to mark pieces of prose I want to return to — a sentence in a Markdown file that needs rewording, a paragraph that needs a citation.

A plan.md document in acme with a phrase highlighted in yellow. A terminal shows the acme-styles compositor: layer h contains one run at rune offset 4055, length 31, color :h (yellow).
A plan.md document in acme with a phrase highlighted in yellow. A terminal shows the acme-styles compositor: layer h contains one run at rune offset 4055, length 31, color :h (yellow).

Language Servers

Fazlul Shahriar's 9fans/acme-lsp connects Acme windows to language servers — gopls for Go, clangd for C and C++, and others via standard LSP.

I've added some features to my fork acme-lsp:

The fork also carries Daniel Moch's configurable FormattingOptions (#85, since merged upstream), which the jdtls settings below use, and Gregor Best's fixes for the Dart language server's completion, formatting and hover (#83). Daniel Moch also wrote one of the Acme essays cited above.10

Put runs the configured code actions, such as source.organizeImports, and formats the file. The L command handles navigation and the rest: L def, L refs, L hov, L rn, L fmt, and L ca to run a server's code actions on the selection. L ws+ adds a workspace root on the fly. ⌘B and ⌘⇧B run Ldef and Lrefs (see Hotkeys), and Lframe resolves JVM stack frames through acme-lsp for the plumber.

acme-lsp serves its language servers as files:

acme-lsp/
  ls          the proxy L talks to
  gopls       one file per configured server; write a JSON-RPC
  clangd      request, read its response (9p rdwr)
  …
  20/         one directory per window, as in acme's index
    ls        the window's language server
    uri       the window's file as an LSP URI
    lang      its language ID

The configuration lives in ~/lib/acme-lsp/config.toml. A few settings apply to every server, and each server gets a command, log files, and the options it reads at initialization:

FormatOnPut = true
CodeActionsOnPut = ["source.organizeImports"]
SemanticHighlighting = true

[Servers.gopls]
Command = ["gopls", "serve"]
StderrFile = "gopls.stderr.log"
LogFile = "gopls.log"

[Servers.gopls.Options]
hoverKind = "FullDocumentation"
semanticTokens = true

[Servers.yaml-ls]
Command = ["yaml-language-server", "--stdio"]

[Servers.yaml-ls.Options.yaml.schemaStore]
enable = true
url = "https://www.schemastore.org/api/json/catalog.json"

The JVM requires more setup. jdtls needs Java 21 to run, though my projects targeted 17, and needs the lombok agent injected. A wrapper script in ~/lib/acme-lsp/ sets both, isolating the server's Java from the rest of the environment:

#!/usr/bin/env rc
# ~/lib/acme-lsp/jdtls
JAVA_TOOL_OPTIONS='-Xmx4g -Xms1g -Xss8m -javaagent:'$home'/lib/acme-lsp/lombok.jar'
JAVA_VERSION=21
JAVA_HOME=`{/usr/libexec/java_home}
path=($JAVA_HOME/bin $path)
jdtls $*

Most of the configuration is the options each server reads at initialization. jdtls takes Eclipse's preferences, which I set to match IntelliJ's import layout and to reach into dependencies:

[Servers.jdtls]
Command = ["/Users/cptaffe/lib/acme-lsp/jdtls", "-data", "/tmp/jdtls-workspace"]

[Servers.jdtls.FormattingOptions]
TabSize = 4
InsertSpaces = true

[Servers.jdtls.Options.settings.java.format]
enabled = false

# IntelliJ's class count to use import with '*'
[Servers.jdtls.Options.settings.java.sources.organizeImports]
starThreshold = 5
staticStarThreshold = 3

[Servers.jdtls.Options.settings.java.completion]
importOrder = ["", "javax", "java", "#"]

[Servers.jdtls.Options.settings.java.references]
includeAccessors = true           # getters, setters and builders
includeDecompiledSources = true   # cross-reference into dependencies

[Servers.jdtls.Options.settings.java.contentProvider]
preferred = "fernflower"          # IntelliJ's decompiler

metals imports the build without asking, since Acme has no dialog for its prompts, and serves a page for the requests it would otherwise show:

[Servers.metals.Options]
isHttpEnabled = true              # http://localhost:5031/

[Servers.metals.Options.metals]
autoImportBuild = "all"
enableSemanticHighlighting = true

The same files make the IDE parts scriptable. acme-lsp's L exec ran a server's own command; Lexec does the same over the 9P files, for the server -s names or the one acme-lsp gives the window:

#!/usr/bin/env rc
# Lexec [-s server] command [arg...]

flagfmt='s server'
args='command [arg ...]'
if(! ifs=() eval `{getflags $*} || ~ $#* 0){
	usage
	exit usage
}
server=$flags
if(~ $#server 0 && ! ~ $winid '')
	server=`{9p read acme-lsp/$winid/ls >[2]/dev/null}
if(~ $#server 0){
	echo 'Lexec: no language server; use -s' >[1=2]
	exit server
}

cmd=$1
shift
jq -nc --arg c $cmd '{jsonrpc: "2.0", id: 1, method: "workspace/executeCommand", params: {command: $c, arguments: ($ARGS.positional | map(fromjson))}}' --args $* \
	| 9p rdwr acme-lsp/$server \
	| jq -c 'if .error then (.error.message + "\n" | halt_error(1)) else .result end'

Scripts on the language server

A JVM stack frame such as at com.example.Foo.bar(Foo.java:42) names a class member, not a file path, so the plumber's default rules can't open it. I use Lframe to solve this — an rc script that asks the language server where the frame's source is, through Lexec, and plumbs the result:

#!/usr/bin/env rc
# Lframe frame line - resolve a JVM stack frame to its source through
# acme-lsp and plumb it.
#
#   frame  full stack frame, e.g. com.example.Foo.bar(Foo.java:42)
#   line   line number, parsed from the frame by the plumbing rule
#
# The server is the one acme-lsp gives $winid, or else the frame's
# extension names it: .java and .kt go to jdtls, .scala to metals.
# jdtls takes the bare frame and returns a URI; metals wants it after
# "at " and returns an object with the URI in .uri.

if(! ~ $#* 2){
	echo 'usage: Lframe frame line' >[1=2]
	exit usage
}
frame=$1
line=$2

server=()
if(! ~ $winid '')
	server=`{9p read acme-lsp/$winid/ls >[2]/dev/null}
if(~ $#server 0){
	switch($frame){
	case *.java:* *.kt:*
		server=jdtls
	case *.scala:*
		server=metals
	case *
		echo 'Lframe: no language server for '$frame >[1=2]
		exit server
	}
}

switch($server){
case jdtls
	file=`{Lexec -s jdtls java.project.resolveStackTraceLocation '"'$frame'"' | jq -r 'sub("^file:(//)?/?"; "/")'}
case metals
	file=`{Lexec -s metals resolve-stacktrace-location '"at '$frame'"' | jq -r '.uri | sub("^file:(//)?/?"; "/")'}
case *
	echo 'Lframe: '$server' cannot resolve stack frames' >[1=2]
	exit server
}
if(~ $#file 0 || ~ $file null){
	echo 'Lframe: no location for '$frame >[1=2]
	exit location
}
echo $file:$line | plumb -i -d edit

The plumbing rule for Java frames:

type    is      text
data    matches '([a-zA-Z0-9_\.]+\.[A-Z0-9\$_][A-Za-z0-9\$_]*\.[a-z\$][A-Za-z0-9\$_]*\([A-Z0-9\$_][A-Za-z0-9\$_]*\.java:([0-9]+)\))'
plumb   start   Lframe $1 $2

For Scala, I extended metals (#7711) with resolve-stacktrace-location, which Lframe calls for .scala frames.

This is a powerful feature. You can tail stack trace logs from production in an Acme win, and right-click them to navigate straight to the file and line in your open Java or Scala project! A killer feature from IntelliJ works in Acme with just a few lines of shell script atop our beautifully simple interface.

Go names that are not paths, a test's name in go test output or a method in a panic, get the same treatment by hand. Lstack trims TestFoo/SubTest or main.(*Server).Serve to the bare name, asks gopls for it with workspace/symbol over the same files, and plumbs where it is defined:

file=`{
	printf '%s' $sym \
	| jq -Rsc '{"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":.}}' \
	| 9p rdwr acme-lsp/$server \
	| jq -r --arg sym $sym '
		(.result // [])
		| map(select(.name == $sym))
		| if length > 0 then
			.[0].location
			| .uri[7:] + ":" + (.range.start.line + 1 | tostring)
		  else empty end'
}
echo $file | plumb -i -d edit

A small java.rc uses Lexec to ask jdtls for the project's classpath, or the test classpath when the file is a test, and the JVM jdtls runs on. plan9port's rc incorrectly handles long `{} output. `{} should produce one long word, which rc models as a single-entry list, but when a word exhausts a pre-allocated 8 KB buffer, rc ends the entry there, drops the next character, and makes the rest a subsequent list entry; so even if the list were re-concatenated, that character is lost, and exported to the environment the entries are joined by a control character. Plan 9's rc grows the buffer instead. To work around this, java.rc links each jar into .jars/ at the project root and puts .jars/* on the classpath. Ljrun, Ljdb and Ljshell run the class, debug it, or open jshell with that classpath, and Ljdef falls back to javap when a definition has no source.

# ~/bin/java.rc
flag e +

# Classpath is longer than 8k bytes and corrupted as env var
# Instead, link all jars into a .jars folder at the root of the project
# Assumption: jar names are unique, alternatively we could hash their full path

# If the current file is a test file, use the test classpath.
scope=runtime
if (~ `{Lexec -s jdtls java.project.isTestFile "file://$%"} true) {
	scope=test
}

# Navigate to the project root
respf=`{mktemp}
Lexec -s jdtls java.project.getClasspaths "file://$%" '"{\"scope\": \"'$scope'\"}"' >$respf
project=`{jq -r '.projectRoot | sub("^file:(//)?/"; "/")' <$respf}
mkdir -p $project/.jars
cd $project/.jars

# Touch the lock file to prevent multiple operations on this folder
if (test -f classpath.lock) {
	echo 'Another operation in progress? Otherwise, rm '`{pwd}/classpath.lock >[1=2]
	exit locked
}
if not touch classpath.lock

# TODO: respect spaces in items

# Only update as needed
jq -r '.classpaths[]' <$respf | sort >classpath.lock
rm $respf
if (! test -f classpath)
	touch classpath
diff classpath.lock classpath | 9 awk '
	/^< .*\.jar$/ { print "ln -s", $2 }
	/^> .*\.jar$/ { print "rm `{basename", $2, "}" }' \
	| tee updates \
	| rc

mv classpath.lock classpath

# Add non-jars to the classpath
classpath=($project'/.jars/*' `{9 grep -v '\.jar$' <classpath})

CLASSPATH=`{echo $classpath | tr ' ' ':'}
cd $project

# If jdtls knows a JVM location, use it.
JAVA_HOME=`{Lexec -s jdtls java.project.getSettings "file://$%" '["org.eclipse.jdt.ls.core.vm.location"]' | jq -r 'to_entries[] | .value'}
if (~ $"JAVA_HOME '') {
	echo 'Could not determine JVM location from language server' >[1=2]
	exit usage
}
path=($JAVA_HOME/bin $path)
The wrappers that use it
#!/usr/bin/env rc
# ~/bin/Ljexec
# Open an rc session in a new win window at the project root, with the project's classpath, with the current Java runtime's bin on path.
# If the current file is a test file, use the test classpath.

. $home/bin/java.rc

if (~ $#* 0) {
	echo 'Ljexec cmd...' >[1=2]
	exit usage
}
exec $*
#!/usr/bin/env rc
# ~/bin/Ljwin

if (~ $#* 0) {
	*=(rc)
}
Ljexec win $*
#!/usr/bin/env rc
# ~/bin/Ljshell

Ljwin jshell $*
#!/usr/bin/env rc
# ~/bin/Ljavap

Ljexec javap $*
#!/usr/bin/env rc
# ~/bin/Ljrun

package=`{9p read acme/$winid/body | 9 awk '/^package .*;/ { print substr($2, 1, length($2)-1); exit }'}
class=`{9 basename $% .java}

# Anything before -- is a JVM option, e.g. -Dspring.profiles.active=dev
while (! ~ $#* 0 && ! ~ $1 --) {
	JDK_JAVA_OPTIONS=$"JDK_JAVA_OPTIONS' '$1
	shift
}
shift

# Move to project root, set path and classpath
. $home/bin/java.rc

# TODO: Refresh and reload classpath on Get
Watch java $package.$class $*
#!/usr/bin/env rc
# ~/bin/Ljdb

package=`{9p read acme/$winid/body | 9 awk '/^package .*;/ { print substr($2, 1, length($2)-1); exit }'}
class=`{9 basename $% .java}

# Anything before -- is a JVM option, e.g. -Dspring.profiles.active=dev
while (! ~ $#* 0 && ! ~ $1 --) {
	JDK_JAVA_OPTIONS=$"JDK_JAVA_OPTIONS' '$1
	shift
}
shift

# Move to project root, set path and classpath
. $home/bin/java.rc

# TODO: Refresh and reload classpath on Get
win jdb $package.$class $*
#!/usr/bin/env rc
# ~/bin/Ljbuild

# Move to project root, or try to find pom.xml in the current directory
cd `{Lexec -s jdtls java.project.getClasspaths "file://$%" '"{\"scope\": \"runtime\"}"' | jq -r '.projectRoot // "." | sub("^file:(//)?/"; "/")'}

if (test -f pom.xml) {
	# Attempt to detect parent pom(s)
	while (grep '<parent>' <pom.xml >/dev/null && test -f ../pom.xml)
		cd ..

	MAVEN_ARGS='-B -Dorg.slf4j.simpleLogger.defaultLogLevel=warn'
	exec Watch -r mvn clean compile
}

if (test -f build.gradle) {
	if (test -x gradlew) {
		exec Watch -r ./gradlew compile
	}
	exec Watch -r gradle compile
}

echo "Not sure how to build: no pom.xml in project" >[1=2]
#!/usr/bin/env rc
# ~/bin/Ljdef
# Ljdef attempts L def, and if there is no definition available, decompiles the class with javap

# Attempt to get definition
def=`{L def -p}
if (! ~ $def '') {
	# Drop snippet at the end
	exec plumb `{echo $def | awk -F: '{ print $1 ":" $2 }' }
}

# Parse class and method from hover output
classmethod=` {L hov | awk '
	# example: String com.example.Outer.Inner.getName()
	/ [a-z0-9_\.]+\.[A-Z0-9\$_][A-Za-z0-9\$_]*\.[a-z][A-Za-z0-9_]*\(/ {
		match($2, /\.[a-z][A-Za-z0-9_]*\(/)
		print substr($2, 0, RSTART-1), substr($2, RSTART+1, RLENGTH-2)
	}
	# example: com.example.Outer.Inner
	# which is actually the class com.example.Outer$Inner
	/^[a-z0-9_\.]+\.[A-Z0-9\$_][A-Za-z0-9\$_.]*$/ {
		print $1
	}
'}

# Move to project root, set path and classpath
. $home/bin/java.rc

{
	if (~ $#classmethod 2)
		echo 'See method '$classmethod(2)
	javap $classmethod(1)
} | plumb -i -d edit -a 'action=showdata filename=+javap/'$classmethod(1)

# TODO: Use IntelliJ's fernflower decompiler
# See: https://youtrack.jetbrains.com/issue/IDEA-175638/Please-release-fernflower-decompiler-as-a-standalone-jar
# See: https://github.com/fesh0r/fernflower?tab=readme-ov-file#command-line-options
# CLASSPATH=$CLASSPATH:'/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/java-decompiler/lib/java-decompiler.jar'
# java org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true target/classes/$classmethod(1).class src/

Filename handlers map paths to servers, first match wins, and each carries the language ID the server expects:

[[FilenameHandlers]]
Pattern = "[/\\\\]go\\.mod$"
LanguageID = "go.mod"
ServerKey = "gopls"

[[FilenameHandlers]]
Pattern = "\\.go$"
LanguageID = "go"
ServerKey = "gopls"

[[FilenameHandlers]]
Pattern = "\\.tsx$"
LanguageID = "typescriptreact"
ServerKey = "vtsls"

Beyond gopls, clangd, jdtls and metals, I run ty for Python and tsgo for TypeScript (or pyright and vtsls), and rust-analyzer, sourcekit-lsp for Swift, terraform-ls, helm-ls, yaml-language-server, taplo, marksman, texlab, and ltex-ls-plus for grammar in prose.

The whole configuration:

~/lib/acme-lsp/config.toml
# ~/lib/acme-lsp/config.toml
#
# WorkspaceDirectories are sent to every server as workspace roots at
# startup; terraform-ls needs them to scope its module discovery. `L ws+`
# adds one on the fly.
#
# CodeActionsOnPut is global: a server without the action logs a warning
# and skips it.

WorkspaceDirectories = []
FormatOnPut = true
# "source.generate.toString", "source.generate.hashCodeEquals"
CodeActionsOnPut = ["source.organizeImports"]
SemanticHighlighting = true

[Servers]

# ── Go ────────────────────────────────────────────────────────────────────────
# go install golang.org/x/tools/gopls@latest
[Servers.gopls]
Command = ["gopls", "serve"]
StderrFile = "gopls.stderr.log"
LogFile = "gopls.log"

[Servers.gopls.Options]
hoverKind = "FullDocumentation"
semanticTokens = true

# ── Java ──────────────────────────────────────────────────────────────────────
# brew install jdtls
# The wrapper at ~/lib/acme-lsp/jdtls sets JAVA_TOOL_OPTIONS (Lombok agent,
# heap: -Xmx4g -Xms1g -Xss8m) and selects Java 21 via java_home.
[Servers.jdtls]
Command = ["/Users/cptaffe/lib/acme-lsp/jdtls", "-data", "/tmp/jdtls-workspace"]
StderrFile = "jdtls.stderr.log"
LogFile = "jdtls.log"

[Servers.jdtls.FormattingOptions]
TabSize = 4
InsertSpaces = true

# symbols = { includeSourceMethodDeclarations = true }

[Servers.jdtls.Options.settings.java.format]
enabled = false
# settings = {url = "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"}

# https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/0b3651f030e2e68e43019268f35880a07aa7a8c5/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java#L345-L367
[Servers.jdtls.Options.settings.java.sources.organizeImports]
# Taken from IntelliJ at File > Settings > Editor > Code Style > Java > Imports > Class count to use import with '*'
starThreshold = 5
staticStarThreshold = 3

# https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/0b3651f030e2e68e43019268f35880a07aa7a8c5/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java#L381-L382
# https://stackoverflow.com/a/54794714
# Blank lines are gathered from java.format.settings; ensure
# org.eclipse.jdt.core.formatter.blank_lines_before_imports is 1
# (Google style sets it to 0). See: https://github.com/redhat-developer/vscode-java/issues/2980
[Servers.jdtls.Options.settings.java.completion]
importOrder = ["", "javax", "java", "#"]

# https://sublimelsp.github.io/LSP-jdtls/ https://sookocheff.com/post/vim/neovim-java-ide/
[Servers.jdtls.Options.settings.java.references]
includeAccessors = true           # include getters/setters/builders in find-references
includeDecompiledSources = true   # cross-reference into decompiled deps

[Servers.jdtls.Options.settings.java.contentProvider]
preferred = "fernflower"          # IntelliJ's decompiler

# ── Scala ─────────────────────────────────────────────────────────────────────
# brew install metals scalacenter/bloop/bloop
# https://scalameta.org/metals/docs/integrations/new-editor
# NOTE: .bsp/sbt.json caches the sbt path; re-import build after sbt upgrades.
# The wrapper at ~/lib/acme-lsp/metals sets heap flags, selects Java 17,
# and builds its classpath with Coursier.
[Servers.metals]
Command = ["/Users/cptaffe/lib/acme-lsp/metals"]
StderrFile = "metals.stderr.log"
LogFile = "metals.log"

[Servers.metals.Options]
# HTTP UI at http://localhost:5031/ (needed for editors that lack showMessageRequest)
isHttpEnabled = true

[Servers.metals.Options.metals]
# https://scalameta.org/metals/docs/integrations/new-editor#import-build-when-changes-detected-without-prompting
autoImportBuild = "all"
enableSemanticHighlighting = true

# ── C / C++ ───────────────────────────────────────────────────────────────────
# Xcode Command Line Tools (xcrun --find clangd)
# ccls kept for reference but has no FilenameHandler — clangd handles C/C++.
# https://9lab.org/9port/acme-with-lsp/
[Servers.ccls]
Command = ["ccls"]
StderrFile = "ccls.stderr.log"
LogFile = "ccls.log"

[Servers.clangd]
Command = ["clangd", "--log=error"]
StderrFile = "clangd.stderr.log"
LogFile = "clangd.log"

# ── Python ────────────────────────────────────────────────────────────────────
# uvx auto-fetches pyright from PyPI in an isolated env (no global install needed)
[Servers.pyright]
Command = ["uvx", "--from", "pyright", "pyright-langserver", "--stdio"]
StderrFile = "pyright.stderr.log"
LogFile = "pyright.log"

# ── Shell ─────────────────────────────────────────────────────────────────────
# npx auto-fetches bash-language-server on first use
[Servers.bash-lsp]
Command = ["npx", "--yes", "bash-language-server", "start"]
StderrFile = "bash-lsp.stderr.log"
LogFile = "bash-lsp.log"

# ── Rust ──────────────────────────────────────────────────────────────────────
# rustup component add rust-analyzer
[Servers.rust-analyzer]
Command = ["rust-analyzer"]
StderrFile = "rust-analyzer.stderr.log"
LogFile = "rust-analyzer.log"

# ── Swift / Objective-C ───────────────────────────────────────────────────────
# Bundled with Xcode Command Line Tools
[Servers.sourcekit-lsp]
Command = ["/Library/Developer/CommandLineTools/usr/bin/sourcekit-lsp"]
StderrFile = "sourcekit-lsp.stderr.log"
LogFile = "sourcekit-lsp.log"

# ── Terraform ─────────────────────────────────────────────────────────────────
# brew install hashicorp/tap/terraform-ls
#
# terraform-ls requires `terraform` in PATH. acme-lsp launches with a minimal
# env (no shell profile), so the asdf shim dir is absent. The Env block below
# supplies ASDF_DIR, ASDF_DATA_DIR, and a PATH that includes the shims so
# `asdf exec terraform` resolves correctly.
#
# terraform-ls also needs workspace roots to index modules — without them it
# spins in a Discover loop from "/". List them in WorkspaceDirectories, or
# use `L ws+`.
#
# Note: CodeActionsOnPut = ["source.organizeImports"] does not apply to
# terraform-ls (it only supports source.formatAll.terraform); the resulting
# warning on Put is harmless.
[Servers.terraform-ls]
Command = ["terraform-ls", "serve"]
StderrFile = "terraform-ls.stderr.log"
LogFile = "terraform-ls.log"

# ── JSON ──────────────────────────────────────────────────────────────────────
# npm install -g vscode-langservers-extracted
[Servers.json-lsp]
Command = ["vscode-json-language-server", "--stdio"]
StderrFile = "json-lsp.stderr.log"
LogFile = "json-lsp.log"

# ── TOML ──────────────────────────────────────────────────────────────────────
# brew install taplo
[Servers.taplo]
Command = ["taplo", "lsp", "stdio"]
StderrFile = "taplo.stderr.log"
LogFile = "taplo.log"

# ── Ruby ──────────────────────────────────────────────────────────────────────
# brew install ruby && gem install ruby-lsp
# Binary at /opt/homebrew/lib/ruby/gems/4.0.0/bin/ruby-lsp
[Servers.ruby-lsp]
Command = ["ruby-lsp"]
StderrFile = "ruby-lsp.stderr.log"
LogFile = "ruby-lsp.log"

# ── TypeScript / JavaScript ───────────────────────────────────────────────────
# npm install -g @vtsls/language-server
# Wraps the same tsserver VS Code uses: reads tsconfig.json, resolves
# node_modules, honors path aliases. Handles .ts, .tsx, .js, .jsx.
[Servers.vtsls]
Command = ["vtsls", "--stdio"]
StderrFile = "vtsls.stderr.log"
LogFile = "vtsls.log"

# ── YAML ──────────────────────────────────────────────────────────────────────
# brew install yaml-language-server
# Covers Kubernetes manifests, GitHub Actions, docker-compose, etc.
# Settings are delivered via workspace/configuration (now supported).
[Servers.yaml-ls]
Command = ["yaml-language-server", "--stdio"]
StderrFile = "yaml-ls.stderr.log"
LogFile = "yaml-ls.log"

[Servers.yaml-ls.Options.yaml]
validate    = true
hover       = true
completion  = true
format      = { enable = true, proseWrap = "preserve", printWidth = 100 }

[Servers.yaml-ls.Options.yaml.schemaStore]
enable = true
url    = "https://www.schemastore.org/api/json/catalog.json"

[Servers.yaml-ls.Options.yaml.kubernetesCRDStore]
enable = true

# ── Helm ──────────────────────────────────────────────────────────────────────
# brew install helm-ls
# Understands Helm templates, values.yaml, Chart.yaml across the
# repo. Use `L ws+` when opening a new chart.
# helm-ls internally proxies yaml-language-server for chart .yaml files;
# do not also attach yaml-ls to Helm template files (no duplicate diagnostics).
[Servers.helm-ls]
Command = ["helm_ls", "serve"]
StderrFile = "helm-ls.stderr.log"
LogFile = "helm-ls.log"

[Servers.helm-ls.Options."helm-ls"]
logLevel = "warn"

[Servers.helm-ls.Options."helm-ls".valuesFiles]
mainValuesFile                  = "values.yaml"
lintOverlayValuesFile           = "values.lint.yaml"
additionalValuesFilesGlobPattern = "values*.yaml"

[Servers.helm-ls.Options."helm-ls".helmLint]
enabled         = true
ignoredMessages = ["icon is recommended"]

[Servers.helm-ls.Options."helm-ls".yamlls]
# enabled = true lets helm-ls proxy yaml-language-server internally for
# chart .yaml files, giving Kubernetes schema validation inside templates.
# diagnosticsLimit caps noisy yamlls errors on incomplete templates.
enabled          = true
path             = "yaml-language-server"
diagnosticsLimit = 50

[Servers.helm-ls.Options."helm-ls".yamlls.config]
completion = true
hover      = true

[Servers.helm-ls.Options."helm-ls".yamlls.config.schemas]
kubernetes = "templates/**"

[Servers.helm-ls.Options."helm-ls".yamlls.config.schemaStore]
enable = true
url    = "https://www.schemastore.org/api/json/catalog.json"

# ── Dockerfile ────────────────────────────────────────────────────────────────
# brew install dockerfile-language-server (installs as docker-langserver)
[Servers.dockerfile-ls]
Command = ["docker-langserver", "--stdio"]
StderrFile = "dockerfile-ls.stderr.log"
LogFile = "dockerfile-ls.log"

# ── Protobuf ──────────────────────────────────────────────────────────────────
# cargo install protols
# include_paths: well-known types from Homebrew protobuf.
# Per-repo protols.toml files handle local proto/ roots and
# chain_rpc_request_response renaming.
[Servers.protols]
Command = ["protols"]
StderrFile = "protols.stderr.log"
LogFile = "protols.log"

[Servers.protols.Options]
include_paths = ["/opt/homebrew/include"]

# ── Markdown ──────────────────────────────────────────────────────────────────
# brew install marksman
# Cross-file wiki-links, ToC generation, outline view.
[Servers.marksman]
Command = ["marksman", "server"]
StderrFile = "marksman.stderr.log"
LogFile = "marksman.log"

# ── Rego / OPA ────────────────────────────────────────────────────────────────
# brew install regal
# Lints and navigates Rego policy files.
[Servers.regal]
Command = ["regal", "language-server"]
StderrFile = "regal.stderr.log"
LogFile = "regal.log"

# ── LaTeX ─────────────────────────────────────────────────────────────────────
# brew install texlab
# Full-featured: completion, go-to-definition, references, formatting.
# Settings delivered via workspace/configuration.
# hover.symbols = "glyph" avoids the default "image" mode which sends base64
# PNG data — garbage in any terminal client.
[Servers.texlab]
Command = ["texlab"]
StderrFile = "texlab.stderr.log"
LogFile = "texlab.log"

[Servers.texlab.Options.texlab]
diagnosticsDelay = 500

[Servers.texlab.Options.texlab.hover]
symbols = "glyph"

[Servers.texlab.Options.texlab.chktex]
onOpenAndSave = false
onEdit        = false

[Servers.texlab.Options.texlab.build]
onSave              = false
forwardSearchAfter  = false

# ── LaTeX / Markdown grammar & spelling ───────────────────────────────────────
# brew install ltex-ls-plus  (maintained fork of the archived ltex-ls)
# LanguageTool-based: grammar, spelling, style in LaTeX and Markdown.
# Dictionary words: ~/.config/ltex/words.en-US.txt  (one word per line)
# Disabled rules:  ~/.config/ltex/disabled.en-US.txt
# Settings delivered via workspace/configuration.
# JVM heap controlled by JAVA_OPTS in the launchd plist.
[Servers.ltex-ls]
Command = ["ltex-ls-plus"]
StderrFile = "ltex-ls.stderr.log"
LogFile = "ltex-ls.log"

[Servers.ltex-ls.Options.ltex]
enabled            = ["latex", "markdown"]
language           = "en-US"
checkFrequency     = "save"
diagnosticSeverity = "information"

[Servers.ltex-ls.Options.ltex.dictionary]
"en-US" = [":~/.config/ltex/words.en-US.txt"]

[Servers.ltex-ls.Options.ltex.disabledRules]
"en-US" = [":~/.config/ltex/disabled.en-US.txt", "EN_QUOTES"]

[Servers.ltex-ls.Options.ltex.latex.commands]
"\\cite{}"   = "dummy"
"\\cite[]{}" = "dummy"
"\\ref{}"    = "dummy"
"\\eqref{}"  = "dummy"
"\\label{}"  = "ignore"
"\\todo{}"   = "ignore"

[Servers.ltex-ls.Options.ltex.latex.environments]
verbatim    = "ignore"
lstlisting  = "ignore"
minted      = "ignore"
equation    = "ignore"
align       = "ignore"
align_star  = "ignore"

# ── Python, TypeScript, HTML at home ──────────────────────────────────────────
[Servers.ty]
# Astral's Python type checker; ~/bin/ty links to the uv tool install.
# Without a workspace ty indexes its cwd, which under 9init is /.
Command = ["sh", "-c", "cd \"$HOME/src\" && exec ty server"]
StderrFile = "ty.stderr.log"
LogFile = "ty.log"

[Servers.tsgo]
# TypeScript 7 native compiler; ~/bin/tsgo links to bun's global install.
Command = ["tsgo", "--lsp", "--stdio"]
StderrFile = "tsgo.stderr.log"
LogFile = "tsgo.log"

[Servers.html]
# VS Code's HTML server, run by bun because Homebrew's node is broken.
# It formats only when Options.provideFormatter is true.
Command = ["bun", "/Users/cptaffe/.bun/bin/vscode-html-language-server", "--stdio"]
StderrFile = "html.stderr.log"
LogFile = "html.log"

# ── Foundation plans ──────────────────────────────────────────────────────────
[Servers.fdn]
# Foundation plans (.fdn): ~/src/foundation, make lsp (formats on Put)
Command = ["fdn-lsp"]
StderrFile = "fdn-lsp.stderr.log"

# ── FilenameHandlers ──────────────────────────────────────────────────────────
# Patterns are Go regexps matched against the full file path.
# The first matching handler wins.

[[FilenameHandlers]]
Pattern = "[/\\\\]go\\.mod$"
LanguageID = "go.mod"
ServerKey = "gopls"

[[FilenameHandlers]]
Pattern = "[/\\\\]go\\.sum$"
LanguageID = "go.sum"
ServerKey = "gopls"

[[FilenameHandlers]]
Pattern = "\\.go$"
LanguageID = "go"
ServerKey = "gopls"

[[FilenameHandlers]]
Pattern = "\\.java$"
LanguageID = "java"
ServerKey = "jdtls"

[[FilenameHandlers]]
Pattern = "\\.scala$"
LanguageID = "scala"
ServerKey = "metals"

[[FilenameHandlers]]
Pattern = "\\.(h|c|def)$"
LanguageID = "c"
ServerKey = "clangd"

[[FilenameHandlers]]
Pattern = "\\.(cpp|cc|cxx|hpp)$"
LanguageID = "cpp"
ServerKey = "clangd"

[[FilenameHandlers]]
Pattern = "\\.pyi?$"
LanguageID = "python"
ServerKey = "ty"         # pyright at work

[[FilenameHandlers]]
Pattern = "\\.(sh|bash|zsh|ksh)$"
LanguageID = "shellscript"
ServerKey = "bash-lsp"

[[FilenameHandlers]]
Pattern = "\\.rs$"
LanguageID = "rust"
ServerKey = "rust-analyzer"

[[FilenameHandlers]]
Pattern = "\\.swift$"
LanguageID = "swift"
ServerKey = "sourcekit-lsp"

[[FilenameHandlers]]
Pattern = "\\.(m|mm)$"
LanguageID = "objective-c"
ServerKey = "sourcekit-lsp"

# TypeScript / JavaScript. Split by extension so each carries the LanguageID
# the server needs to pick the right mode.
[[FilenameHandlers]]
Pattern = "\\.tsx$"
LanguageID = "typescriptreact"
ServerKey = "tsgo"       # vtsls at work

[[FilenameHandlers]]
Pattern = "\\.ts$"
LanguageID = "typescript"
ServerKey = "tsgo"       # vtsls at work

[[FilenameHandlers]]
Pattern = "\\.jsx$"
LanguageID = "javascriptreact"
ServerKey = "tsgo"       # vtsls at work

[[FilenameHandlers]]
Pattern = "\\.(js|mjs|cjs)$"
LanguageID = "javascript"
ServerKey = "tsgo"       # vtsls at work

[[FilenameHandlers]]
Pattern = "\\.(tf|tfvars)$"
LanguageID = "terraform"
ServerKey = "terraform-ls"

[[FilenameHandlers]]
Pattern = "\\.json$"
LanguageID = "json"
ServerKey = "json-lsp"

[[FilenameHandlers]]
Pattern = "\\.toml$"
LanguageID = "toml"
ServerKey = "taplo"

[[FilenameHandlers]]
Pattern = "\\.rb$"
LanguageID = "ruby"
ServerKey = "ruby-lsp"

[[FilenameHandlers]]
Pattern = "\\.(yaml|yml)$"
LanguageID = "yaml"
ServerKey = "yaml-ls"

[[FilenameHandlers]]
Pattern = "[/\\\\]templates[/\\\\].*\\.yaml$"
LanguageID = "helm"
ServerKey = "helm-ls"

[[FilenameHandlers]]
Pattern = "[/\\\\]Dockerfile(\\.[^/\\\\]*)?$"
LanguageID = "dockerfile"
ServerKey = "dockerfile-ls"

[[FilenameHandlers]]
Pattern = "\\.proto$"
LanguageID = "proto"
ServerKey = "protols"

[[FilenameHandlers]]
Pattern = "\\.(md|markdown)$"
LanguageID = "markdown"
ServerKey = "marksman"

[[FilenameHandlers]]
Pattern = "\\.rego$"
LanguageID = "rego"
ServerKey = "regal"

[[FilenameHandlers]]
Pattern = "\\.(tex|bib|cls|sty|dtx|ins)$"
LanguageID = "latex"
ServerKey = "texlab"

[[FilenameHandlers]]
Pattern = "\\.html?$"
LanguageID = "html"
ServerKey = "html"

Session Init

All these services need to start in the right order and stop when Acme exits. I originally used launchd agents with PathState dependencies. They were unreliable: launchd's readiness detection is poll-based, so a service that crashed and recovered within the polling window left its dependents holding stale connections, requiring a manual launchctl kickstart.

9init is a session init system written in the spirit of Plan 9's startup conventions. Services are rc scripts in ~/lib/9init/*.rc with TOML frontmatter in comment lines — adding a service is creating a file, removing one is deleting it, and the scripts are directly executable with rc for debugging. Readiness is a socket: when $NAMESPACE/name appears, the service is ready. No health checks, no HTTP probes. EVFILT_VNODE NOTE_WRITE on the namespace directory fires the moment a socket appears or disappears, so there is no polling.

9init watches for Acme. When $NAMESPACE/acme appears (when I run the a script), dependents start. When it disappears, dependents stop in reverse topological order.

ninit9initfontsrvfontsrv ninit->fontsrv plumber plumber ninit->plumber acme acme ninit->acme watches styles acme-styles acme->styles hotkey acme-hotkey acme->hotkey focused acme-focused acme->focused ts acme-treesitter styles->ts lsp acme-lsp styles->lsp hl acme-highlight styles->hl

The frontmatter for acme-styles.rc:

#!/usr/bin/env rc
# socket  = "acme-styles"
# after   = ["acme"]
# restart = "on-failure"

exec acme-styles -styles $home/lib/acme/styles

9init exposes a 9P filesystem for observability:

init/
  ctl        write "stop <name>" or "restart <name>"
  status     read: one line per service with state and PID
  svc/
    acme-lsp/
      log    streaming log output (blocking read)

9p read init/svc/acme-lsp/log tails the LSP log in real time.

Every 9P service I wrote for this stack sits on p9srv (github.com/cptaffe/p9srv), our library for posting plan9port namespace services. Post(name) creates a socketpair, forks 9pserve unix!$NAMESPACE/name, blocks until the socket appears, and returns the pipe end. The three-layer stack:

clientsclientssocket $NAMESPACE/name clients->socket 9P mux 9pserve socket->mux unix socket p9srv p9srv mux->p9srv pipe srv9p srv9p p9srv->srv9p 9P messages

Closing

LSP diagnostics could be surfaced the same way: language servers already push error ranges with textDocument/publishDiagnostics on every edit, and acme-lsp could write those spans to a "diagnostics" layer — syntax errors painted inline with a red background, warnings in yellow.

The infrastructure described here — compositor, seq guards, anchor model, session init, socket lifecycle library — is roughly fifteen thousand lines of Go and C that didn't exist two years ago. The editor itself is thirty-two years old and substantially unchanged.

Rob Pike, in "Systems Software Research is Irrelevant":27

Narrowness of experience leads to narrowness of imagination.

In the lower-right win window of the opening screenshot, 9p read acme-styles/20/style | head prints the composed style stream that acme reads to color window 20. The left column shows acme.c, highlighted by the same pipeline it hosts. The editor is reading its own compositor output.

Appendix: Plan 9's namespaces in Linux

Plan 9's per-process namespaces were ported to Linux as mount namespaces, the first of several namespace types that would eventually form the foundation of Linux containers. Interest in the Plan 9 model has continued — a 2022 FOSDEM talk43 revisited the cpu command as an alternative to SSH, arguing that exporting the local namespace to a remote machine is a more natural model than forwarding individual ports or tunneling X11.

Alexander Viro's 2001 patch44 described them as "Plan 9 per-process namespaces (sans unions so far)" with a companion rfork.c, "an equivalent of rfork(RFNAMEG) on Plan 9." The patch merged into Linux 2.5.2 as CLONE_NEWNS, the first of eight namespace types.45 Eric Van Hensbergen's 2005 OLS paper46 traced the lineage in detail and demonstrated applications including v9fs (the Linux port of 9P) and plan9port. Eric Biederman's 2006 OLS paper47 proposed expanding the namespace model to cover PID, network, and user isolation, writing: "The Plan 9 inspired mount/filesystem namespace has already proved how this can be done."

A fundamental difference remains in the privilege model. In Plan 9, rfork(RFNAMEG) is an unprivileged call — any process can copy its namespace and modify the copy. In Linux, creating a namespace requires CAP_SYS_ADMIN.48 User namespaces (CLONE_NEWUSER) were introduced to bridge this gap, allowing unprivileged processes to create namespaces. The tradeoff was security: Google's kCTF VRP research found that 44% of kernel exploits required unprivileged user namespaces as part of their exploit chain. In 2016, Kees Cook proposed a sysctl to restrict the feature; Eric Biederman, who created user namespaces, argued the problems lay in other kernel interfaces being amplified by namespaces.49 Debian shipped with kernel.unprivileged_userns_clone=0 until Bullseye (2021), when they enabled user namespaces by default after concluding that "the risk of enabling it is outweighed by the security benefits it provides."50 Ubuntu took a different approach in 23.10, adding AppArmor-based restrictions that selectively allow or deny unprivileged user namespaces per application.51

All Linux processes share the root namespace by default; isolation requires an explicit clone() or unshare() call. Linux namespaces are used primarily for container isolation (Docker, podman, runc) and application sandboxing (Flatpak, bubblewrap). In Plan 9, each process inherits a copy of its parent's namespace at rfork and can bind or mount freely within it. There is no bind(1) in the Linux shell, and Linux's VFS is an internal kernel abstraction; Plan 9's 9P is an IPC protocol that any program can speak. Linux also restricts unprivileged mounting to filesystems explicitly flagged FS_USERNS_MOUNT, such as FUSE. v9fs,52 the Linux port of 9P contributed to by Eric Van Hensbergen and Russ Cox among others,53 does not yet carry this flag — an unprivileged user cannot mount a 9P service into their namespace without root or a user namespace.


  1. Rob Pike, Acme: A User Interface for Programmers, USENIX Winter 1994. ↩︎

  2. Russ Cox, A Tour of Acme, video, 2012. Cox coins "integrating development environment" here — an integrating environment that draws Unix tools in, as opposed to an integrated one that replaces them. ↩︎

  3. Dennis Ritchie and Ken Thompson's The UNIX Time-Sharing System outline filters in section 6.2, introducing pipes:

    An extension of the standard I/O notion is used to direct output from one command to the input of another. A sequence of commands separated by vertical bars causes the Shell to execute all the commands simultaneously and to arrange that the standard output of each command be delivered to the standard input of the next command in the sequence.

     ↩︎
  4. Niklaus Wirth and Jürg Gutknecht, Project Oberon: The Design of an Operating System, a Compiler, and a Computer. Pike's immediate predecessor to acme was Help, "an experimental system written a few years ago as a first try at exploring some of Oberon's ideas in an existing operating system." ↩︎

  5. Rob Pike, Dave Presotto, Sean Dorward, Bob Flandrena, Ken Thompson, Howard Trickey, and Phil Winterbottom, Plan 9 from Bell Labs, Computing Systems, 1995. ↩︎

  6. Introduction to the Plan 9 File Protocol, 9P. ↩︎

  7. Rob Pike et al., The Use of Name Spaces in Plan 9. ↩︎

  8. Rob Pike, reply to "Why does Acme only show text?," comp.os.plan9, July 2009. ↩︎

  9. Russ Cox, Plan 9 from User Space. ↩︎

  10. Daniel Moch, Acme: The Un-Terminal, January 2025. ↩︎ ↩︎

  11. Mathieu Bivert, On Plan9's Acme. ↩︎

  12. Alex Karle, Exploring Acme, Plan 9, and NO_COLOR. ↩︎

  13. Satyajit Ranjeev, Bitter Sweet Acme. ↩︎

  14. jcs, Using Acme, Irreal. ↩︎

  15. David Yates, Text editors II: Acme, 2015. ↩︎

  16. Acme as an editor, JLOUIS Ramblings, 2013. ↩︎

  17. Tao of Acme. ↩︎

  18. Peter Mikkelsen, How I Started Using Acme. ↩︎

  19. Ruben Berenguel, Editor Magic: emacs, vim, acme and the return key, 2012. ↩︎

  20. Ruben Berenguel, Extensibility in the Acme Text Editor, 2013. ↩︎

  21. Differences from Acme, Anvil editor. ↩︎

  22. evbogdanov/acme, a community-maintained collection of scripts and tools. ↩︎

  23. Ask HN: Does anyone use Acme editor?, Hacker News, 2020. ↩︎

  24. bind(1) — Plan 9 manual. ↩︎

  25. newuser(8) — Plan 9 manual. ↩︎

  26. Brad Fitzpatrick, Tailscale on Plan 9 from Bell Labs, April 2025. Tailscale's Plan 9 port opens /net/ipifc/clone to create a virtual interface, writes bind pkt to configure it, and reads and writes raw IP packets through /net/ipifc/N/data. ↩︎

  27. Rob Pike, Systems Software Research is Irrelevant, Utah, 2000. Pike describes the cpu command: "From the local terminal, you get a shell window on the remote cpu server, but all the local resources — the file system, the network, even the devices — are still available." ↩︎ ↩︎

  28. Rob Pike, A Concurrent Window System. See also The Implementation of Newsqueak, Software—Practice and Experience, 1990. ↩︎

  29. Rob Pike, 8½, the Plan 9 Window System. ↩︎

  30. Rob Pike, The Rio Window System. ↩︎

  31. cpu(1) — Plan 9 manual. ↩︎

  32. Tom Duff, Rc — The Plan 9 Shell, Bell Labs. ↩︎

  33. Rob Pike, Plumbing and Other Utilities. ↩︎

  34. Acme's Edit command takes sam's command language, where , addresses the whole file and > sends it to a command's standard input. Rob Pike, A Tutorial for the Sam Command Language. ↩︎

  35. no-color.org — a convention for disabling color output. ↩︎

  36. CGEventTap — macOS Quartz Event Services. Requires Accessibility permission. ↩︎

  37. The ctl file accepts lowercase commands: put, get, del, delete. The capitalized forms (Put, Del) are the tag-level names that acme recognizes when middle-clicked as commands. ↩︎

  38. Russ Cox, reply to "Using the Acme Editor," 9fans, August 2008. Full thread. ↩︎

  39. Hacker News, comment by bravura, March 2022. ↩︎

  40. Nikita Prokopov, I am sorry, but everyone is getting syntax highlighting wrong. ↩︎

  41. Russ Cox, reply in "Syntax highlighting in Acme?," Inferno mailing list, February 2006. ↩︎

  42. Rune offsets because Acme is internally rune-oriented and source files routinely contain non-ASCII text. ↩︎

  43. The Plan 9 cpu command, FOSDEM 2022. ↩︎

  44. Al Viro, per-process namespaces for Linux, LKML, February 2001. ↩︎

  45. Mount (2002), UTS (2006), IPC (2006), PID (2008), network (2008-2009), user (2007-2013), cgroup (2016), and time (2020). See namespaces(7). ↩︎

  46. Eric Van Hensbergen, Glen or Glenda: Empowering Users and Applications with Private Namespaces, OLS 2005. ↩︎

  47. Eric Biederman, Multiple Instances of the Global Linux Namespaces, OLS 2006. ↩︎

  48. unshare(2) — "allows a process to disassociate parts of its execution context that are currently being shared with other processes." ↩︎

  49. Jonathan Corbet, Controlling access to user namespaces, LWN, January 2016. ↩︎

  50. Debian Bullseye release notes, §5.1.14. ↩︎

  51. Ubuntu 23.10 restricted unprivileged user namespaces. ↩︎

  52. Eric Van Hensbergen and Ron Minnich, Grave Robbers from Outer Space: Using 9P2000 Under Linux, FREENIX Track, USENIX 2005. ↩︎

  53. v9fs: Plan 9 Resource Sharing for Linux, Linux kernel documentation. Contributors include Ron Minnich, Maya Gokhale, Eric Van Hensbergen, Latchesar Ionkov, and Russ Cox. ↩︎