Emacs in 2018: My Year in Review

A couple weeks ago, I was chatting with a colleague (@captainepoch, follow him!) about the time required to configure Emacs so that it makes a difference in your workflow. I think that the investment is absolutely worth it, although I can understand that the friction gets smoother with time. That also made me think how, regardless the time, it seems that even experienced Emacs users are constantly surprised by new configurations, plugins or even built-in functions. Emacs’ importance in the free software community makes it have such an extent that is too great to be completely mastered.

That made me think of an interesting experiment: what about making a review of the configuration changes I applied during the year? This can make a great introspection exercise of the evolution in my workflow that can be nice to see through the years. This assumes that I will be using Emacs more than a year from now, which is likely to happen but still, there is also a chance that I will be using a different editor next month. In any case, let us have a little reflection on how the year developed for my way of interacting with Emacs.

Workflow changes

The main point of including Emacs in one’s toolbox is not to lose sanity and time configuring an editor with no purpose: using it is the fast track to have a modular and malleable workflow, that can be easily modified and bent to new needs. This section includes a short elaboration on how I modified the way I used Emacs in 2018.

Emacs server + systemd + i3

Without any doubt, the most radical change for my whole computing setup this year. Moving to Antergos (based in Arch Linux) from macOS opened a new range of possibilities, and one that was interesting for me ever since was tiling managers. I was always interesting in exwm, an Emacs based window manager; but was never able to properly configure it in the wild to my liking. I decided to go with i3, which offered tiling window management close to the one that Emacs provides. And then, I had the vision: I could try to include Emacs as a service in the OS and creating a new client every time I pressed S-RET.

This was a weird thought for me: I had always disregarded running the Emacs daemon for no particular reason. However, after a super simple configuration (writing an Emacs service for systemd is absurdly easy) I was able to include it in the system, and realising how wrong I was this whole time. Now I can also run emacsclient -e "<elisp>" to evaluate run code in the Emacs daemon, which is an awesome way to externally setting configurations or checking for mail regularly (more about that later). This has been a complete game changer, and a much better alternative to include Emacs in a higher level of existence than using exwm. The things to work on are negligible compared to benefits, but I still have to be able to gain again a functional C-x o (other-window) between visible frames for it to be complete.

Blog publish using only org-mode

One of the most interesting changes in my personal workflow was to move this whole blog’s generation and management into Emacs. I previously used a combo of hugo and org-mode, which I have to admit was a super fast solution. However, some friction in the formatting and a great deal of will to dive into org-mode stuff made me move the complete generation to org-publish, which offers a great freedom at the expense of some configuration work to leave everything to my taste: I wrote my very own CSS stylesheetfor the blog, and created a publishing workflow including all my quirks and details. It can be rough on the edges sometimes, but the fact of it being so personal makes it easy to find what is happening when something is wrong. There were, however, several gotchas: I found some changes not propagating or some articles not being published, which was due to the fact that the an error in the process (which can be due to a programming mode in a snippet failing) interrupts the entire publishing process. The other common error was how to republish every post when I decided to change the footer (disclaimer: the footer is stored as a variable in org). Solving this was as simple as running C-u M-x org-publish to invalidate the previous cache and re-publish the whole website.

Overall, I am supper happy with this shift in tools and how it enables me to further configure the workflow. There are some little details that are still to be developed if I find the time and ways to do it: a proper RSS feed for the blog, and a self-generating list of posts in the index (don’t tell anyone because it is a secret, but it is currently a hard-coded list of posts).

Email configuration

This year, the GitHub acquisition by Microsoft finally triggered me to pivot my git workflow to a more libre solution. The most promising alternative was sr.ht, which is a new player in the game that advocates for a more orthodox, email-centric git workflow. This made me realize that using ProtonMail for this kind of issues was absolutely inadequate (mainly because of its closed standards and the fact that Bridge’s SMTP server is capped). For that reason, I started using Fastmail (which is indeed a great service) and is much easier and smooth to configure for local use. My current mail setup includes using OfflineIMAP to download the mail (using a systemd trigger to download it periodically) and mu and mu4e to read the mail. The last step to get a complete workflow is to find a way to write a mail in org and export it to HTML when sent. However, I have to admit that sending HTML is far from being one of my top priorities.

Bibliography manager and PDF reader

I have used the beautiful package org-ref for years to manage references, but this year the inclusion of pdf-tools to read books and papers in Emacs was an absolute game changer. The fact that I can search through a compilation of all the technical books I have and instantly link the references to notes about the work I am searching for is just priceless. And, surprisingly, pdf-tools is not just a way to read PDFs in Emacs: in my experience, pdf-tools is the best PDF reader for GNU/Linux. I was not able to find a better reader that included a comfortable way to annotate and highlight texts. Overall, I am really happy with this aspect of my workflow and I cannot see any obvious room for improvement in it.

Terminal emulation

This is the last frontier, and the last struggle. I am really text-oriented, and although using Emacs has moved me away from it in several tools (git, ssh, and even directory management). However, using the terminal is inevitable from time to time. However, there is not a completely satisfactory solution for this problem. Although ansi-term comes close to solve the issues (and it is, indeed, my choice when running it in Emacs), there are some problems that are inherent to Emacs: the “everything is a buffer” philosophy comes at the cost of not having real input redirection, which is key to having a real terminal emulator. Terminal keys also concur in some collisions with regular Emacs environments, so it can feel awkward or not-organic. Today, when I have to run Emacs I choose to run ansi-term with the presets of the sane-term package.

New language configurations

Another great deal of configuration updates was due to new languages that I decided to give a shot in 2018. This section includes a small review of each of them and their support for Emacs.

Nim

A very interesting language whose spiritual ancestor is (allegedly) Python, tries to have a clean syntax while offering good performance. Nim is compiled and one of its great features include the generation of standalone binaries. My trip with Nim was short-lived (I just wanted to try it out) but its configuration for Emacs was short and easy: much like a C, one needs very few help of tools to be productive in Nim, and nim-mode does a great work with it. If you need a compiled, performing and concise language, give Nim a shot.

Clojure

Probably my favourite new language of 2018, Clojure is a very opinionated Lisp dialect that runs in the JVM. It has a good performance basically related to the fact that advocating for functional programming makes Clojure able to include concurrency and parallelism in a mostly trivial way in the execution. I really enjoy writing Clojure and, although I don’t share all of them, I have to admit that the points of view of Rich Hickey are always interesting.

Clojure setup for Emacs cannot be better: cider includes great syntax highlighting, all the Lisp benefits in Clojure and a companion REPL for each project. I have to admit that writing Python now sucks a bit more after trying Clojure in cider. Also, being a Lisp means a lot of parenthesis, so rainbow-delimiters and paredit (or sp-use-paredit-bindings if you use smartparens like me) are going to be two loyal helpers.

Kotlin

I did not intended to write Kotlin a lot, but I really wanted to check out how the long promised future of Android looked. Kotlin is a clean, closer to functional programming language than Java that works on the JVM and aims to be a modern substitute of the former. My experience with Kotlin was short as well, but the configuration was a breakthrough for me: my Kotlin configuration relied on the Language Server Protocol to hook up all the features of IntelliJ and inject them directly into my Emacs. This experiment had some rough edges and breaking points, but the possibilities it unleashed were amazing: Using the LSP, we could be able to add all the IDE capabilities to the editor without sacrificing our configuration of choice. Oh, what a time to be alive, right?

R

Calling myself a data scientist and working as one, at some point became necessary to have at least some notions of R. And I will be honest, I did not enjoy it that much: R’s incredible amount of abstraction and meta-programming carry some performance costs, and I had a difficult time seeing any real usage for it outside exploratory data analysis. If you ask anyone, they will tell you how R has to be written in RStudio, a great IDE that includes everything you may need. However, ess-mode can provide you with most of the goodies you need without ever leaving Emacs. There is not much more to add; ess-mode is a humongous package that should include everything that you will ever need and probably a couple things more.

New packages and tools

This section includes some brief discussion of a couple topics that can be interesting in the future or that I suddenly discovered to have great support in Emacs.

Language Server Protocol

Developed by Microsoft for Visual Studio Code, the Language Server Protocol aims to run a client-server architecture in which the server offers all kinds of code linting, completion and documentation via a standard protocol for all kinds of clients: new clients can be developed for different editors and IDEs to benefit from this technology.

In my experience, although it looks like a bright future, the LSP in Emacs still carries a bit of overhead and delay when trying to use it to its full extent. I have tried Python, which is the one with the greatest lag (probably because of the nature of the language) and IntelliJ integration, which can be a bit cumbersome). For that reason, I would recommend everyone to keep an eye on this technology during this next year, and pray for Microsoft not to disappoint or betray us all!

Docker tools

I never even wondered how Emacs could help me manage different Docker containers, but some packages actually offer a nice integration and I have found myself not reaching for the shell when doing some tasks related to it. Mainly, docker offers a Magit-like hydra menu to handle images and containers from Emacs, dockerfile-mode offers syntax highlighting when writing Dockerfiles and docker-tramp allows you to connect via TRAMP to the insides of a container and… Do whatever you need to in there! It actually surprised me a bit how good and natural these tools feel once you get your grips on them.

SQL console

Lately in work I have been in need of using SQL more than I used to, and I have been actively trying to improve my SQL skills by tinkering with PostgreSQL. However, it actually surprised me how Emacs includes a built-in SQL suite that includes SQL highlighting and SQL consoles for all major players: SQLite, MySQL/Maria, PostgreSQL, MongoDB… And once again, this is built in! Your Emacs has it as well, so don’t hesitate to pop a new SQL console in your editor if you ever need one.

Honorable mentions

And last, but not least, some important remarks about the state of my configuration or other Emacs features I discovered this year.

Aesthetics

There are 3 main things that define the aesthetics of my editor as of now:

  • The color theme is Solarized Light. I never liked light themes, but I really enjoy working with Solarized’s smooth colors and nice contrast.
  • The mode-line is configured using almost the defaults of moody and minions, two incredible packages developed by Jonas Bernoulli, the developer of Magit. They create a simplistic mode-line based on ribbons.
  • The font used is Overpass Mono, developed by Red Hat. This serif, rounded typography seems like one of the most comfortable monospaced fonts I have seen in a while. However, during a good part of the year I also used Iosevka and it is still my preferred font for other elements in my desktop such as the terminal emulator or polybar.

A screenshot of my Emacs configuration

avy-jump

One of the packages that I ignored the most until I realized how wrong I was, avy-jump offers a magical way of jumping around in Emacs buffers. I was never super interested in it, but giving it a shot and tinkering to find what works for me was a key moment in it. Currently, the setup includes having avy-goto-char-timer bound to M-SPC. That means that once I press M-SPC, I am prompted to write the text that I want to move to inside the buffer. I can write as much as I want, and it will stop and run once I am half a second without writing. If the text I entered is unique, the point jumps to that text automatically. Else, I am offered the regular avy letters prompt with all the occurrences in the buffer. Incredibly useful, and it does even work as a party trick!

magit-todos

This small tool offers a simple and yet super useful functionality: it includes all lines marked with TODO in your code right in your magit-status prompt. For someone which already uses TODO as a tag in code comments and works with Magit all the time, this was a no-brainer. It is really comfortable and you should check it out.

hexl-mode

More of a curiosity rather than an actual mode I have to use, hexl-mode is yet another incredible and built-in mode that is able to display binary data like a hex editor used for reverse engineering. hexl-mode is super useful to explore binaries, which is something I have indeed done quite a few times with good results thanks to this mode. Still, probably not the mode you are going to be using most, but it is one of these things that few Emacs users know they have available.

Wrapping up

This year, I started using GNU/Linux in my personal computer. I also started using it in my work computer; my first full-time Computer Science work, which I also started in 2018. After all these years in college, it can be hard to admit, but it was probably the year in which I learnt the most. So, let’s hope to be able to write yet another essay like this in December 2019, sharing all the things I was able to learn in this next year. Happy New Year!