Emacs & Org mode

2 minute read

For anyone lacking experience with command-line-type computer software, the approach to using packages such as Emacs can be intimidating.

Luckily, the transition from Graphical User Interfaces (GUIs), with icons and pull-down menus, to Emacs is facilitated by the fact that Emacs also provides access to many features through icons and familiar pull-down menus.

It is true, to a certain extent, that this type of package was born as an advanced text editor, especially suited for programmers. However this does not mean that it’s utility is confined solely to this category of users.

Emacs can be thought of as having many layers, with each layer providing functionality of a different kind. At the most basic level, text editing in the Emacs environment is a very powerful feature. Whether you intend writing an R script, a Python program, a diary, this post, or a novel, Emacs can do it. This is why Emacs is often defined as the swiss-army knife of text editors or a one environment for all solution. The common theme between these tasks is that they are all text-based.

How would Emacs “know” whether a certain text is intended to be a piece of R code or a chapter in your book? The short answer is that it mainly depends on the filename’s extension (i.e. the part of the filename which is after the dot): a file whose name is “filename.r” will be interpreted by Emacs as being an R script, while “filename.txt”… yes, right! a simple text file. So, then “filename.org” is an Org mode file.

Whenever Emacs “sees” a filename extension it “recognizes”, it will automatically adopt the corresponding “mode”, which means that Emacs will become responsive to commands which are appropriate for that given mode. Accordingly, Emacs’s menu bar will change to reflect the availablity of commands specific to the mode currently in use. In R mode, Emacs will “understand” the R programming language, appropriately highlighting R functions and objects in the text.

Coming to the point of this post, filenames with the “.org” extension will put Emacs into Org mode, and this literally opens a world of possibilities! Org mode in itself is a suprisingly rich and complex tool. The header to the org mode web site says: “Your life in plain text”, which is not an exaggeration! Org mode provides a very clean interface, allowing the user to concentrate on content and, probably more importantly, makes it very easy to organize outlines into sections and subsections (called trees), which can be expanded and collapsed and/or hierarchically reordered with great ease.

Nonetheless, Org mode takes care of all the formatting behind the scenes, allowing the production of an elegant ‘pdf’ document complete with title page, table of contents and page numbering, literally at the click of a mouse. This, on its own would be enough to justify it’s use but, as the name implies (Org is short for organizer) Org mode also provides the user with a rich set of functions to manage agendas and to-do lists, all of which need not reside in a document of their own: they can be typed into any document at any time (and remain hidden in the ‘pdf’ output, if so desired) and then collected and organized, again at the click of a mouse.