Taking Acme for a spin

Posted on

acme · plan9 · gentoo

I've been inspired to take the Acme for a more serious spin. Here are some of things I learned early on, and couple of tips and tricks.

Instead of installing Plan 9 (which I’ve tried), I’ll be trying out the Linux port to see if I can get used to Acme as my daily editing driver. On Gentoo Linux, Acme is available through the dev-util/plan9port package.

For the best experience, you should have the following setup:

% export PLAN9=/opt/plan9
% export PATH="$PATH:$PLAN9/bin"

On Gentoo Linux this is done automatically, so there’s nothing extra that needs doing.

Getting started

The Acme introduction that’s really piqued my interest (again) is A Tour of the Acme Editorhttp://research.swtch.com/acme by Russ Cox, so that’s where I started. I’ve rewatched the video a few times now, every time I picked up some new little detail that I’d missed previously.

The first thing to get comfortable with is that the mouse is quite heavily used. Getting used to button 2 (middle-click) being the “execute” function is not that difficult, but I often click button 2 when browsing files and folders (where I need to click button 3 - right-click).

Fonts

I typically like programming with a monospace font, but the default font is not a monospace font.

There are other fonts to try out, they’re all shipped in the /opt/plan9/font folder. To launch Acme with a different font, run:

acme -f /opt/plan9/font/lucm/unicode.9.font

Be sure to target a file with the .font suffix. For now my preferred font is the lucm font shown above.

Using system fonts

I’ve gotten used to the JetBrains Mono font family, it’s just very crisp to read in my experience.

To use system fonts we need to start fontsrv(4)https://9fans.github.io/plan9port/man/man4/fontsrv.html which provides access to host fonts

% fontsrv &
% 9p ls font

which will print out a long list of fonts found on the system. The JetBrains Mono I typically use is given as “JetBrainsMonoNL-Light”. To launch Acme with this font:

% acme -f /mnt/font/JetBrainsMonoNL-Light/11a/font

There are actually two arguments for fonts accepted by Acme: -f and -F. The former (default) is the variable width font and the latter is known as the fixed-width font.

Among the builtin commands understood by Acme (like Cut and Paste) there’s Font. Just putting “Font” somewhere in a tag or body of a window and clicking it with mouse button 2 toggles the font of the body the window.

Running in i3 I’ve ended up with the following way to launch Acme:

% cat $HOME/.bin/Acme
#!/bin/bash
i3 exec --no-startup-id acme -f /mnt/font/DroidSans/11a/font -F /mnt/font/DroidSansMono/11a/font

I am really trying to get used to a sans-serif non-monospaced font for writing code - I find it pretty cool to have an editor that supports pretty much any fonts you want and can set fonts for individual windows.

Tips and tricks

Formatting files

The source for this page itself is written in Markdown (converted with commonmark). I like to have the source wrapped at 80 characters just so the input for the HTML is also readable if all you have is the source. Acme itself doesn’t do automatic word-wrap as you might have in something like Vim with :set tw=80.

What we can do instead is to put the text |fmt -80 in the tag of a file buffer, highlight some text in the body we want to format, select all of the command (including the -80 argument) and clicking button 2. This should format the selected text in place.

If you write C and want to format with clang-format, the same thing applies: Write out |clang-format in the tag, select the entire body of the window and execute. To select the whole buffer execute the text Edit ,.

Setting the tab width

Put Tab N in the tag or body of a window, select and click with button 2. Boom! Supposedly the variable $tabstop is also respected.

Running a terminal

Type “win” somewhere and execute it with button 2, and a kind of “terminal” is executed. Win is a C program that receives commands when executed with button 2, and returns the output of those commands. So it works sort of like a terminal. The benefit here is that the buffer holding input and output is a regular acme buffer, and things like recalling and editing a previous commands amounts to searching/scrolling back in the buffer, editing and executing a selection of text.

Things to try out

Re{sources,ferences}

There are quite a few good resources out there.