Two Wrongs

Emacs Calendar with Fixed Width Font

Emacs Calendar with Fixed Width Font

This is the one time I’ll encourage you to call me weird. But here’s the thing.

I have started using proportional11 variable-width fonts for writing code.

Proportional Default

In fact, the default font in my Emacs configuration is a proportional font, so that’s what automatically gets applied everywhere.

Why do I do this? I don’t know. I kind of like it, actually. It feels like it makes it easier to read stuff when the gestalt images of words are more distinguished from each other. You should try it, too!22 But be prepared for the ridicule. A friend of mine once used a proportional font when programming – I think maybe because it was the default in the editor he used that one time – and I mocked him for it several years. We have come full circle.

However, this is not quite enough. There are a few places in Emacs where fixed-width fonts are pretty much required for sensible operation.

For those cases, I have configured some exceptions to that rule. Some exceptions that get fixed-width fonts are tables rendered with ascii – and – the subject of this document, the Calendar interface used in Emacs by Org mode.

Fixed-width in Calendar Mode

To get this, we have to first ensure the fixed-pitch face is actually set to use a fixed-width font33 I set the height (font-size) property to 80% of the default font, because the glyphs in my fixed-width font are slightly larger than the ones in the variable width font.:

(custom-theme-set-faces
  'user '(fixed-pitch
          ((t :family "Luxi Mono" :height 0.8))))

Then we have to enable the Emacs-built in support for buffer-local faces44 Normally, this should be easier. The reason it’s so complicated is that the creators of the Calendar mode never stopped to think that the user might want to customize the font used for the main Calendar numbers. If they had (like reasonable sane people would), then it would have been much easier., and turn it on whenever we open the Calendar mode.

(use-package face-remap :config
  (setcq buffer-face-mode-face '(:inherit fixed-pitch))

  (add-hook 'calendar-mode-hook #'buffer-face-mode))

This will launch the buffer-local face whenever Calendar mode is started. And that should be it!