Emacs For Productivity

I use Emacs a lot. Not only do I do I use it as my development tool for nearly all my programming work, but I also use it as my task management tool, my calendar and my email client. As I've added more and more tips and guides for using Emacs, I thought I'd collect them in one place.

Of all the packages I use to enhance my productivity in emacs, use-package is perhaps the most useful. With it, I can automatically download and install other packages from the emacs package databases when it detects they're missing. Since I'm constantly switching computers, virtual machines, and operating systems, having this functionality is essential for making sure I don't miss a beat when I'm starting from scratch; I simply clone the emacs config files from my GitHub repository and open emacs and I'm almost immediately ready to go.

This short guide shows how to ensure that use-package also automatically installs, and how to get the most out of the use-package features.

I'm sure we've all had the same experience with "fully-featured" todo-list and project management programs: each had their own niceties, but none quite delivered on their promise. I've been using the built-in org-mode within Emacs for quite some time now, so I figured it was high time that I really made it my own.

I'm glad I did.

For the last year, many of my customization options were taken directly from the unbelievably detailed Guide by Bernt Hansen and remained unchanged for some time. However, the guide contained an overwhelming amount of information, which made it difficult to determine precisely what features I would find most useful.

Even if you don't use this post for your own configurations, I highly recommend looking at Bernt's exhaustive guide.

I'm writing this short guide in an effort to introduce the features in org-mode which I've found I can't live without. I'll go over how I use org-mode, and it's powerful built-in summary/calendar view known as org-agenda, in both my work and in my hobby projects. I also include some details about how everything was implemented, or at the very least provide the reader with references to understand my code. This guide is only an introduction to my workflow and is by no means self-contained (unlike Bernt's)! Feel free to comment below or get in touch with me if you have any questions.

Org also has some nice export tools built in, so that I can easily share my notes with colleagues.

Who this guide is for: If you've been using Emacs for a while, you should probably try the Vim way of doing things. Too many resources online push people in the direction of giving Spacemacs a try; most such guides are designed to encourage Vim users to try out Emacs and have a habit of alienating established Emacs users such as myself. During my efforts to embrace Evil, Emacs' Vim emulator, I hit a few road blocks and decided I would put this article together to help others through them. Whether you'd like to try out evil-mode or you're simply curious to see how the other half do development, keep reading.

The reverse of this is probably true as well, and if you use Vim I encourage you to give Emacs a try, but that's not the purpose of this guide.

My first thought in conducting this experiment was just to open my mind and learn something new. In addition, my Emacs pinky occasionally bothers me, and I wanted to try a more ergonomic way to appreciate the editing tools I use on a daily basis. This is a log of my experience, and some code for setting up your .emacs.d files. My verdict after roughly a week:

Having tried the Vim way, I won't likely revert to using pure Emacs.

I really love the way everything came together; the modal system of editing has started to change the way I think about composing text and code. The macro system and a couple of other niceties I'll talk about below blew me away, and I've quickly integrated them into how I work. Finally, Evil is quite popular, so many of the packages I use on a regular basis, like magit and org-mode have extensions to add more vim-like default keybindings.

I get a lot of email. I'm also pretty sure you get a lot of email. However, email is still not a solved problem. Each potential email client is acceptable on it's own, yet none of them satisfied all of my desired features:

This is evidenced by the fact that a quick Google search yields no less than ten viable options for email clients on my Mac.

  • The ability to access my email without an internet connection.
  • I travel quite a lot, so this was very important to me.

  • Easily move messages between different folders, which is how I keep all of my emails organized by project.
  • Quick yet powerful search of all my mail messages.
  • Having an auto-updating status indicator that shows me how many unread messages I have.
  • Managing multiple accounts (Gmail for personal emails and Microsoft Exchange for work emails) and syncing local changes so that my phone can still be up-to-date.

If you follow this blog, you'll recognize that I've gotten a bit carried away with migrating the different aspects of my life to operate within the Emacs environment. So it was only a matter of time until I finally decided to give it a shot, and I converged upon a solution which happily satisfies all of the above constraints. Every email service is a bit different so YMMV, but this setup works for me.

I've described at length how I use Emacs and Org as a project management tool. As part of my process, I frequently use Org as a lab notebook, in which I keep track of various bits of data and record both the code I run and various parameters I used in the process. My workflow requires (1) running code, (2) logging the results, and (3) including my own thoughts and analysis in between, a programming paradigm known more generally as literate programming.

A number of folks on Reddit and have pointed out that I don't dive deep enough to really call the content in this post literate programming. Perhaps a more appropriate title would include Literate Scripting; regardless, the content I present here is still an integral part of my Emacs-based workflow.

Org makes it easy to asynchronously execute code for multiple programming languages (and even allows for remote code execution over ssh). For instance, on a recent project of mine I had a few shell scripts that I would occasionally run that would loop through some data files I was generating on a remote machine and return some statistics about them; Org makes it possible for me to do this without having to leave my notes. In this article, I'll go over a few use-cases that illustrate the utility of using Emacs with Org for coding projects and walk you through some of the functionality I couldn't live without.

As an academic, I read a lot of papers. Part of my job is retaining what I read, since deeply understanding the work of others and building upon it is one way I come up with new research ideas. When it comes time to sit down and write a paper, I need to contextualize my ideas in a Related Work section: I include a discussion of other research that has touched upon similar problems or inspired my own work. Over my years in academia, I have settled on an annotated bibliography to manage my own knowledge base of papers.

When I started collecting papers and other references, I added annotations to PDFs. However, this doesn't scale well, since my comments and the documents themselves were difficult to search and lacked easy-access to important metadata. I used Zotero for a while, but that didn't mesh with my workflow either. It was nice enough, but still required that I leave my Emacs environment. In addition, I don't really need the ability to markup PDFs. For a paper I think I may want to find again, I only need a couple of things:

  • A paragraph-long summary of the paper.
  • A BibTeX entry for the paper.

An annotated bibliography is perfect for this. Everything is in one place. It's easy to edit and share. And I can manage the entire thing from within Emacs with ease.