23 September 2017

Writing, because Emacs

Blogging is writing and publishing. I've not been writing here much for lack of a relatively frictionless process. And also because, well, translators on Mac don't seem to have so many issues anymore with the platform. Or maybe they don't really exist. I'm not sure.

Some people say they've moved to Emacs because of org-mode. Emacs? org-mode? The names are probably unknown to most translators. But they're what brought me back to writing, and eventually to publishing, at least here and other places.

Emacs is a venerable text editor. It is one of the first "officially" free programs published ever, and it is the beginning of the Free software movement, in a way. Emacs is in fact more than a text editor. And a lot of people are confused by that because Emacs is before anything a Lisp virtual machine that was made to run on any platform.

Lisp machines used to be hot in the 80s, when research on AI was at its peak. Lisp machines were computers that understood Lisp down to the CPU... And Lisp was the language of choice for AI back then. Lisp itself is the second-oldest programming language still in use today. Its implementation started in autumn 1958 explicitly as a language to research AI at the MIT. A few years later, copyright issues and headhunting resulted in fewer and fewer people able to freely use and develop Lisp, and that's when Emacs was conceived, at first as a way to put Lisp on any possible machine without limiting them to Lisp Machines, to fight against the people who were attempting to close access to that knowledge.

Emacs now looks like a text editor because a text editor is a required tool to write Lisp code. But besides for Lisp code writing, which it does very well, Emacs is able to write any kind of things. And programs in Lisp written for Emacs have been extending Emacs functions to areas that were never envisioned by the original creators.

org-mode is one such program. It does not look like a program, of course. It looks like you're doing things in Emacs and it's easy to organize them because org-mode is here to help you.

I wrote above that a lot of people have moved to Emacs because of org-mode. In Emacs talk, a mode is a group of specialized functions. In my Emacs, I have installed a chess mode, that allows me to play chess in Emacs, a "deft" mode that emulates in Emacs the behavior of Notational Velocity, the famous note taking app for OSX, I also have apples-mode that transforms Emacs into an Applescript editor or writeroom-mode, that works like all the "distraction-less editors" around, except that it turns Emacs into that distraction-less editor. Some people say that Emacs is an operating system and that you don't have to leave it to do your computing. You can browse the web, do your mail, write text, read PDF files, etc.

org-mode was created over the outliner-mode that Emacs provides. Outliners exist everywhere. Mac has many nice outlining applications where you can put notes in a given hierarchy, sort them, search their contents, use them as reminders or as todo lists, etc. org-mode original creators started to add functions to the Emacs outliner, and then everything grew so big that a separate mode was born.

I am just a beginner in Emacs. Although I started using it about 20 years ago, I never got to actually use it because most of my "writing" work then involved regular expressions and the tool of choice on Mac at the time was BBEdit Lite. I still don't do regular expressions in Emacs. When I need to do relatively complex searches, I still switch to BBEdit (Textwrangler is going to be discontinued and BareBones is planning to default BBEdit to a lite version, except for the paying users who'll be able to unlock the full thing).

I am just a beginner but I have traces of Emacs edited files on my machine dating back at least 10 years. I remember meeting a then not yet world-famous Emacs contributor/blogger in Tokyo, almost 13 years ago and showing her an Emacs book in Japanese I had just bought. And I remember reading about and using Emacs at the end of the 90s when I was attempting to install and run Linux on that IBM/Lenovo machine I had just bought when I came to Japan. It worked eventually, but Unicode was not widely spread then and I had to constantly switch between a French environment and a Japanese environment to do my work on Linux, and that was not convenient. So I moved (back) to Mac, which I had started using a few years before, where Emacs then was not as attractive for the casual writer as it is today.

Why Emacs? For me it was not org-mode, which did not exist then. It was just the intuition that Lisp was an amazing language and that I ought to learn it. 12 years ago there was another peak Lisp with the publishing of "Practical Common Lisp". There were Emacs distributions that were tweaked to include the latest Lisp editing environment, there were blogs that discussed the marvels of writing Lisp in Emacs. There were beginning attempts at curating the various libraries that were spread all over the place. There were discussions about creating the best Lisp ever... It was like a Lisp rebirth, and the Emacs mode that everybody talked about then was slime, the best Lisp editing environment.

I never got to go beyond the cover of the Lisp books I kept buying though. And it is only many years later, that org-mode and the articles I kept reading about it finally got me started, along with the nagging feeling that I should be better organized and that I should start writing, not just resume blogging, but write my own stuff. And for that I needed no bells and whistles, no fancy WYSIWYG application, just white characters on a black screen with wide margins and nothing else.

I'm writing this article from org-mode. The article is one "node" in a big "blog.org" file where all the nodes are listed in chronological order, with the date and time I started them in the header title. I start writing an article by calling a "capture template". This one has the name of this blog. I have 9 different templates. One for a big TODO file, one for a personal FAQ where I add questions and answers about all the stuff that I want to know about Emacs, org-mode, git, and various other things. Then I have one for taking various notes, I have a daily journal for things that won't be published, then 2 templates for 2 different blogs (including this one), 2 others for 2 novels I have in mind and a last one for an introduction to Emacs Lisp that I've wanted to write for a long time now.

It took me a while to realize that the feature that would hook me to Emacs was this "capture" thing. org-mode is a lot about headers, subheaders, TODO states, lists, deadlines and calendars and timers. It is a huge planner machine that goes in so many directions that it is not possible to fully use it all. The terms used in the manual are sometimes obscure and the manual itself goes into a lot of details not relevant to the beginning user. So you really have to wander on the net to find the tutorial that works for you, tweak some settings and start. I have 51 documents on my machine that I tagged with "org". I've browsed them all at least once. I keep them for easy reference to see what people do with org-mode, but the documents I consult the most now are the Org Manual and the Emacs manual.

When you start tweaking, it never ends, but it's OK. Your documents are being written in a live Lisp environment. Everything you do, from typing a single letter to reorganizing your paragraphs or checking your calendar is done by calling functions that you can modify right away by just editing and evaluating them. Assigning shortcuts is also a Lisp function away. But you don't have to worry about learning Lisp before you start using Emacs. It just comes, almost naturally, little by little. And it is not difficult. It took me just a few days of reading and researching before proposing code that fixed a bug in an OSX service Emacs.app provided, and that code was eventually accepted for release in Emacs. I was totally new to Emacs Lisp and even though it was only a few lines of trivial code the whole thing was not trivial, but it was not hard to find the issue, understand it, and fix it, because I could do that right there, inside that live Lisp environment that Emacs is.

I wish there was a powerful translation mode in Emacs. There is a po-mode that does interesting things, but it is nowhere near what professional translators use. There was an attempt a long time ago at linking the current target segment of an OmegaT project to Emacs, but the device involved a lot of intermediate technologies (a bridge from Java to Python and then one from python to Emacs if I remember well). Doing CAT based translation work in Emacs is not possible now, as far as I can tell. But that's fine. I just need to know that I have found a pretty good writing environment and that I can just "capture" my thoughts, put them on virtual paper and move on.