Let's just use Emacs

Somewhere around the previous post, I made an outlandish promise that I might try out Celtx to see how well I could write a story in the “novel mode”.

I think I have to take it back. Because Emacs foiled that plan.

And I still can’t believe it.

Emacs as a prose editor. Bah. Pigs are flying.

I’m a long-time Emacs user, and if there’s one thing that bugs me is that Emacs has frequently been in a state of stagnation. As every Emacs fan knows, Emacs is the ultimate text editor – nothing can be better than Emacs. It’s a religious position, kind of like the Apple fandom. So, obviously, you get some pretty heavy cognitive dissonance when you notice that the competing editors are better at something.

And in recent years, Emacs had a lot of things that were just plain outlandishly crappy. Off the top of my mind:

  • Font specification that was bizarrely difficult. Setting fonts was bloody impossible.
  • No soft word wrap.
  • Stone-age widget set in GNU Emacs. Neater widget set in XEmacs, though distinctly not GTK+.
  • Super-ugly font rendering.
  • No support for UTF-8. Later, a hacky support through a third-party package.
  • Bizarre configuration system.

In times when the competitors get things right, it’s easy to start looking for alternatives. These alternatives are not Emacs. And it shows. You use them, and you will experience great pain.

But… It’s always refreshing to see that stuff gets fixed. My greatest pains were experienced years ago when I used XEmacs, which was updated ridiculously slowly, and that pace was still faster than what GNU Emacs had at the time. Much to my surprise, GNU Emacs folks launched version 22. What the hell. I thought we were going to get stuck in version 21 for ages.

And now they’re going at version 23, which is even more amazing.

So, GNU Emacs is actually updated fairly often now, and each new release seems to bring in some outrageously awesome features. UTF-8? We have that now, out of box. Stone-age widget sets? Hell no – you get GTK+ on Linux and Aqua on Mac, fits perfectly to both desktop environments. Ugly fonts? GTK+, Pango and Freetype, yadda yadda yadda. Setting fonts? It’s in the freaking menu now. If you want to put it in ~/.emacs, it’s just (set-face-attribute 'default nil :font "Anonymous Pro 16") or something like that, and voila, you’ve got awesome fonts.

And the biggest, greatest feature to hit Emacs 23?


Or, as the folks who have not been touched by the awesomeness of Emacs say, “soft word wrap”.

Soft word wrap means that it’s infinitely easier to eyes and your mind to edit stuff that’s picky about line breaks. And if stuff is not picky about line breaks, this means you’re not mashing M-q all the time. Suddenly, it’s much less painful to edit wikitext. Writing fiction practically needs soft word wrap; this is pretty much not negotiable. Even this blog post was written in visual-line-mode, even when Markdown isn’t picky about line breaks.

Now, it’d be pretty silly to say that I’m giving Emacs another whirl as a fiction writing environment just because of soft word wrap.

No, I’m giving it another whirl because of all of the other features that Emacs has gained since I last tried it. Two features in particular; these two features totally made me scrap my plans to go out and buy Scrivener.

The first major piece of awesomeness is org-mode. org-mode basically solves one of the problems in way that isn’t intuitive first, but after you notice it, it becomes a “now why the hell didn’t I think of this before”-type idea.

My previous big objection to editing text files was simple: When you work on fiction, you really need to be working on multiple files at once… and these files should be stored in one “project file”. None of the text editors could get this. I loved TextRoom and Bean, but this was really one of the Scrivener features that made me drool. Of course, Celtx solved this problem as well. You could have a specific files for random work-in-progress scenes, and files for scrapped scenes, and things like that. And, of course, separate files for notes. Heck, a categorised database for background information.

org-mode developers, in turn, just ask a relevant big question: “why use separate files when you can conveniently stick the stuff in one file, dammit?”

A piece of fiction can just be a bunch of text paragraphs in an outline file, you know. When someone asks you “can you edit and rearrange individual scenes?”, the answer is simple: well, it’s just a bloody outliner, of course it can do it.

Then the org-mode developers say other fascinating things: “You know that feature in Scrivener where you can add status to your work? We have that. Hell, you can customise the statuses. You know the feature where you can stick random tags to your pieces of fiction? Hell, we have that too. Shit’s fully taggable and searchable. That corkboard thing? Fuck corkboard, we have folding and fuzzy-search hyperlinks – whenever, wherever. Adding comments to the text? Comment lines start with # – you know what to do. And before you ask if you can add text formatting and export as HTML, hell yes, we do those too.”

Basically, org-mode bends the definition of outliners until you realise that outlines are text and text is outline and now you’re a babbling lunatic who no longer makes sense. But it does make sense. I have seen but a fraction of the true genius of this software. I feel like I was listening to Ted Nelson’s rants again. In org-mode, I’m… not editing a document. I’m editing a piece of fiction, one piece at a time. On a computer. In a way that makes sense.

With org-mode, I can just drop my notes in a section called “Notes”. I have a section called “Story”. Underneath, I’ll have chapters and scenes. Whoop de do. After a while, I get “Rejected stuff” and “Stuff that might work better in some other story”.

The second revolutionary new piece of code is darkroom-mode. This mode turns Emacs into a full-screen text editor. Seasoned Emacs users will probably do M-x facepalm at this point and say “you need a special mode for that?” before realising that some people here are stuck using GUIs, and these GUIs need some encouragement to return to the primordial and primitive state.

The sad truth behind full-screen “distractionless” writing programs is that they’re basically very feature-limited text editors. There wasn’t really any problem with this idea as such, but the fact is that the granddaddy of these programs is a proprietary commercial product that sells for $25. Yes, people pay money for feature-limited text editors. In open source land, we call these things “some programmer guy’s first shot at glory, before they realise everyone and their dog has written a limited-feature text editor and starts telling everyone to just use Emacs.”

I’m not condemning these people for trying to sell these products, I just find it ridiculous that they can make money. It’s like dot-com bubble all over again. I’d call the idea of “distractionless” writing programs ridiculous and overhyped, except for the fact that the concept certainly works well enough. I loved bashing text out in last year’s NaNoWriMo and not really looking other directions. I want the same stuff in Emacs.

Now, there are open source projects that implement the same ideas – I’ve used TextRoom and Bean quite successfully. But sooner or later, you’ve got to ask: Why not go the whole hog? Why not use a real text editor? You can make Emacs do this stuff, can’t you? Aww, we have no soft word wrap! …ahem, we now have soft word wrap. Moving on…

And the ridiculous thing is, running Emacs in fullscreen should be easy, right? In Linux, we have virtual consoles. To hell with X11, just go for the good ol’ text mode. Actually, when I was using a dog-old Celeron laptop, I ran Emacs in Linux text console, because the laptop was too puny to ran X11 in the first place.

But temporarily ditching GUI takes time and effort, even if it’s just “flip to the virtual console and log in”. Besides, I’m also working on an OSX laptop; no virtual console here. And here’s where the darkroom-mode kicks in. In GUI, Emacs needs some additional boosting to make it a worthwhile fullscreen editor: alternate colour mode à la Bean, and some additional margin control. Fortunately, darkroom-mode does just this, and seems to work fine.

Add as the sugar in the bottom, I could get markdown-mode, and got blogging covered, too.

Truly, people are making Emacs do everyfriggingthing. And this is awesome. I can now bash text out in Emacs, and edit it in LibreOffice, while Emacs also doubles as my web dev and LaTeX editor, and file conversion assistant. Less programs, more results.

But still, it’s fun to return to Emacs as a fiction editor. When I was a kid, I wrote my first horrible fantasy novel(ette) with DOS Emacs, when Windows 3.1 Write wouldn’t cut it. I also wrote the first Avarthrel stories with Emacs, before abandoning it due to lack of soft word wrap and limited typography. I’ll be happy to see how this renewed relationship works out.

But wait! I hadn’t used VICE in years, but there’s now a full-on Aqua port of VICE for OS X. When I was a kid, I was sure (probably, can’t remember for certain) that I could never fill up the ginormous memory space of 30490 bytes, available in Mini Office II. And yes, MO2 word processor looks just like the vaunted Distractionless Writing Environments™: edit time clock, word counter, and free memory counter – what more do you need? Hit ⌘F and VICE looks and feels just like a real Commodore 64 – just with a better keyboard. Maybe, just maybe, I should prove the kiddy version of me wrong and write a story in MO2. Still, my nano2010 project turned out to be 308171 bytes – yep, I really, really had to check that there wasn’t an extra “1” in the end. I would barely fit that text on a single 5.25” floppy… split on two sides. But short stories? Maybe, maybe…

That, however, kind of reminded me of one of my famous author’s brushes with no-bullshit writing environments of yesteryear:

“I am happy to greet the geniuses [Seymour Rubenstein and Rob Barnaby] who made me a born-again writer, having announced my retirement in 1978, I now have six books in the works and two [probables], all through WordStar.” —Arthur C. Clarke

(And I hear George R.R. Martin dug WordStar too. They’re all wrong! Wrong, I say! WordPerfect 5.1 FTW!)

Update: Follow-up article on further org-mode experiences!


A few words of warning: for a long time I was using Emacs to write prose. I stopped doing so, after halfway in a novel I realized that a few editing sessions ago I must have pressed C- then C-w without noticing and about five pages of a recent work are gone. I wasn't using version-controlled filesystem, and the backup file was lacking too. I had to rewrite the missing part from scratch, I did but shortly after that I switched to Open Office (version control!), and later to Mac with Pages for longer stuff and OmmWriter for short pieces.

It is still possible to lose text this way in a WYSIWYG editor but less likely so as C- isn't a block marking command there.

WordPerfect 5.1 for DOS or nothing.

> No soft word wrap.

I'm not an Emacs expert, but isn't soft wrapping what longlines-mode does?

I tried to leave emacs in the last years. I tried JEdit, then Komodo Edit and Eclipse.
But Emacs rocks. It is a bit too difficult to program in my own opinion, but it rocks.
I'd like to add an utility...

longlines-mode is basically a hack that stitches paragraphs to long lines when you save stuff. visual-line-mode is the real deal: stuff wraps properly as you edit it without any attention from you, edit tools behave logically (e.g. C-k kills to the end of the visible line). It also gives you the ability to just use the linebreaks where you absolutely need them. With longlines-mode, I was still justifying my paragraphs all the time for no reason at all. Not fun.

I've used version control for my writing projects for a long time. But yes, the only time where I actually lost something that I typed was with Emacs. Basically, I fell asleep typing something, ha deleted it at some point, and had saved it. I figured it was not really Emacs's fault. =)

I write fiction. I use emacs. Decades of both. And yet... I've struggled for hours trying to make orgmode work for my fiction and given up repeatedly.

I need a sensible minimum set of orgmode commands that support writing fiction. I'm open-minded, and willing to change my process, if I can find someone who-s already been there and done that. Tell me what you do? Sketch your process for me? I'd be grateful.

Emacs 23.1.1; orgmode 7.8.03.

Sorry for a little bit late reply.

What I usually do is that I have a top-level headline "Story", and additional headlines like "Notes" and "Characters" and "Timeline" and so on. "Story" then has sub-headlines for chapters and scenes.

Your best bet is to just start up the Org-mode documentation and read up some basics. (M-x info, then press "g", type "(org)" (no quotes, but parentheses are required) and hit enter.

Basic skills that you should learn:

- Editing and refreshing the export options. (See "Export options"; refresh the file's properties by hitting C-c C-c while in top of file)

- Adding tags to headlines (C-c C-q). These help you remember stuff.

- Defining TODO statuses. For example, my current WIP has these statuses: "#+TODO: NOTHING STARTED DRAFT REWRITE NEWIDEAS POLISH OK | DONE" - and each story headline has a status that signifies how far I'm from being done.

- Basic markup. How to do /italics/ and so forth.

Remember, I'm not an Org guru either. You can always take small steps toward true mastery. =)

Here's what I use to make my emacs fullscreen in X in Linux:
(defun toggle-fullscreen ()
(set-frame-parameter nil 'fullscreen (if (frame-parameter nil 'fullscreen)
(global-set-key [(meta return)] 'toggle-fullscreen)

Interesting, thanks! (And you're the first commenter to comment on the Drupal incarnation of this website. Well, aside of the spammers. =)