, , , Posted on 13 November 2024 by

Weekly Emacs tips

For over twenty years, I have been using Emacs, first only as a text editor, but later for more and more other things as well. This post starts with a summary of my Emacs journey and ends with an Emacs tip. My aim is to publish a new tip every week. Let’s see if I can stick to that :-).

My Emacs journey

Since roughly the year 2000, I have been using Emacs as text editor and software development environment. It all started with my BSc research project, for which I had to work on a Tektronix X terminal, connected to the faculty’s server running Compaq True64 Unix. At the time, I had only very little experience working with Unix, both from the command line and the graphical CDE, which meant that the PhD student supervising me basically told me what to type, and where. As he was using Emacs, that’s what I ended up using, all the way through my Master’s and my own PhD.

Over those years, my use of Emacs remained pretty basic and my .emacs configuration file grew slowly with snippets I found here and there on the internet. At the time, most programming and data analysis work I did used IDL and Gnuplot and texts were written in LaTeX. Emacs had syntax highlighting for these languages and AucTeX made working with LaTeX much easier (although I only used a fraction of what it offers). And the IDLWave package even supported running IDL interactively inside Emacs! My first step towards using Emacs as an IDE.

All was good.

For about two, three years, my Emacs usage remained more or less the same. I left academia, started a job at a Unix/Linux consultancy company, where I didn’t do much development, but Emacs remained my text editor of choice.

Then, in 2010, I went back to academia as a postdoc in genetic epidemiology and bioinformatics, which meant learning R as well as doing various server administration tasks. By chance, my colleague and later business partner also happend to use Emacs. We had both learned about Org mode, which we started to use for things like literate programming and some task/todo management. I seem to remember that around the same time Emacs development picked up speed and with the help of online platforms like GitHub, code snippets and Emacs packages became easier to find and co-develop. All in all, Emacs become even more central to my work.

When we started PolyOmica in 2015, the scientific development work didn’t change much. However, as a small business keeping track of things like projects, contracts, taxes, etc. is important. Moreover, the administrative load of keeping track of hours for invoicing and the ability to produce reports of the number of hours spent on project tasks only added to the administrative load. Org mode was (and is) a great way to keep on top of things.

In the past ten years or so, the Emacs community seems to have grown a lot, or maybe I just took more notice. Many new packages have been created, including ones like Magit for interacting with Git, ESS for programming in R, Polymode for e.g. writing R Markdown documents, etc., etc. I even tried mu4e to read my e-mail from Emacs, but that didn’t stick (yet?). And more recently, I even created my own Emacs package (very much standing on the shoulders of others, of course) and managed to get it published in the Melpa repository!

So, even though I don’t consider myself an Emacs expert (my Lisp knowledge is tiny), I do consider myself a veteran user. And as I encountered some other Emacs users, some of whom only started using Emacs recently, I thought I’d start publishing some Emacs tips. For people new to Emacs, I also created an opinionated starter Emacs configuration file, mainly focused on things we use in bioinformatics. You can find it in this Gitlab repository. So, without further ado, please find my first Emacs tip below.

Emacs tip #1: the which-key package

The which-key package (see https://github.com/justbur/emacs-which-key) shows what “follow-up” keys are available when you start pressing e.g. C-x or C-c. I still find it very helpful, especially for functions and packages I don’t use very often. Here’s how I configured it:

;;; Show which keys are available for a given prefix
(use-package which-key
  :ensure t
  :custom
  ;; Set the time delay (in seconds) for the which-key popup to
  ;; appear. A value of zero might cause issues so a non-zero value is
  ;; recommended.
  (which-key-idle-delay 1.0)
  :hook
  (after-init . which-key-mode)
  )

No Comments

Let us keep you updated!

Once a month we’ll send you an overview of our newest articles. No spam, we promise.

Thank you for signing up! We've send you an confirmation mail.