Emacs enriched text mode

Ever since Tavis Ormandy got Wordperfect 8 working on modern Linux it’s been bugging me that we don’t have many options for word processing in the terminal.

Thanks to his amazing work, we do now have an enterprise grade word processor running in our terminals. However, there are problems.

Problems with Wordperfect 8

WordPerfect 8 for Unix

The most glaring problems are that it’s closed source, hasn’t been updated in 27 years, and it’s not exactly, user friendly. The PDF manual is ~700 pages! There’s also the file format problem. It’s not a publicly documented format. You can certainly open a .wp file in plenty of software:

  • Libre Office
  • Abiword
  • Google Docs

will all open an old wordperfect document, thanks most likely to libwpd but you’ll only be able to edit it in Wordperfect. Which raises the question,

“will I be able to open / edit these documents in twenty years time?”

So, while wpunix is an interesting piece of software, it’s probably not the best idea to do all your writing with it.

So, as I’m inclined to do, I set about seeing what other options I have for editing documents on the command line.

JOE Editor (Jstar)

Joe jstar mode

I was already familiar with JOE and vaguely remembered that it had a Wordstar emulation mode. I’ve never used Wordstar, but know it’s still considered irreplaceable by some notable users. So, I had a play with it but it’s not quite what I’m after. The only formatting that one could consider somewhat out of the ordinary with Jstar is being able to centre text.

What Should a Word Processor Do?

To my mind, at a minimum, a word processor should be able to:

  • bold, underline and italicize text
  • Centre, left and right align text
  • Justify text
  • Have various types of headings

I was amazed that no such command line program seemed to exist. Yeah sure, we’ve got loads of Markdown editors, but I don’t consider Markdown to be anything related to word processing. I even thought about attempting to make my own format (how hard could it be?!). But luckily, I came across:

RFC 1896 The text/enriched MIME Content-type

For some reason, I always forget than any computer problem was almost certainly solved years ago. And so it was for this problem. RFC 1896 was suggested in 1996 to allow formatting of email messages. Unfortunately, it never caught on. Still, it exists and is a standard and Emacs has an enriched mode! See here for online documentation. Here’s the “source” code for the screenshot at the top of this post:

Content-Type: text/enriched
Text-Width: 70

<flushright>This is right aligned 

</flushright><center>

Here is some <bold>bold </bold>text and here is some that is <italic>italic</italic>.

</center><flushboth>

Enriched mode is a minor mode for editing formatted text files in a
WYSIWYG (What You See Is What You Get) fashion. When Enriched mode is
enabled, you can apply various formatting properties to the text in
the buffer, such as fonts and colors; upon saving the buffer, those
properties are saved together with the text, using the MIME
‘text/enriched’ file format.


Enriched mode is typically used with Text mode (see Text Mode). It is
not compatible with Font Lock mode, which is used by many major modes,
including most programming language modes, for syntax highlighting
(see Font Lock mode).  Unlike Enriched mode, Font Lock mode assigns
text properties automatically, based on the current buffer contents;
those properties are not saved to disk.

</flushboth><center>

<underline>Underlined Heading</underline>

</center>

The only thing that seems to be missing from enriched-mode is increasing the font size. There’s a discussion on the mailing list that goes into detail:

Making selected text larger in enriched mode

Apart from that, enriched-mode seems pretty much perfect for writing.

Using Emacs Enriched Mode

I won’t go into great detail as the documentation link above explains everything, but here are my brief notes:

Type M-x enriched-mode on a new file to activate the mode.1 Then, you only really need to remember two shortcuts:

Alt-o to bring up the Options(?) menu and Alt-j to bring up the Justify menu.

Then, you can just press a single letter:

Emacs enriched mode options menu

Alt-o b to bold for example

Emacs enriched mode justification menu

Alt-j b to justify

Plain Text Benefits

As enriched text is simply plain text with a bit of markup, it’s easily versionable (RCS, Mercurial / Git et al.). You can write a script to convert your enriched text to another format etc.

Conclusion

As I wrote in Why I use GNU Nano post, I don’t use Emacs as my text editor. But, I’ll probably start using it as my word processor instead…

Footnotes

1 I’m trying to find an easy way to start Emacs in enriched mode. Will update post if I find it!