Emacs mode line simplified #

Back in 2017 I posted that I switched from my own custom Emacs modeline to Spaceline. I liked having a simpler configuration with more features. Unfortunately I eventually realized that those features were slowing down my system. In particular, column number, which-function, and selection-info, and my custom unicode display had to be updated on every keystroke. I went back to the default mode line and used this trick to see when it was recalculated:

(defvar-local mode-line-eval-count 0 "Counting :eval")

;;; put this in mode-line-format
(add-to-list
 'mode-line-format
 '(:eval (progn
           (setq mode-line-eval-count (+ 1 mode-line-eval-count))
           (format "%+4d " mode-line-eval-count))))

Every recalculation, the counter increases. By experimenting with the default mode line, I found that having %c in the mode line (column number) causes it to redisplay (almost) every keystroke, and %l (line number) causes it to redisplay when changing lines. I also realized during this experimentation that Emacs felt faster with the default mode line than with Spaceline.

I decided to switch from Spaceline to the default mode line, much closer to my setup before 2017, but simpler, more modular, and matching my tabbar. It feels nice and it looks good. I thought I would miss a few of the fancy features from Spaceline, but I didn't miss them as much as I thought I would. Features I use:

  • Read-only and modified status show a bright color on the left.
  • Project directory and filename are in separate colors.
  • The color theme depends on project (red for work, blue for personal, purple for configuration).
  • Week number ties into my task tracking system.
  • Line number uses Emacs 26's line-numbers-mode instead of the mode line.
Screenshot of Emacs tabbar, line-numbers-mode, and mode-line

I've put a simplified version of the code in a gist.

Labels: