08 Apr 2026
Computing Days Until with Emacs
A recent Mastodon post showing the days until the next U.S. election got me to wonder, “how can I compute that in Emacs?” Turns out, this is trivial with the Org mode function org-time-stamp-to-now doing the timestamp computation for you.
We can wrap org-time-stamp-to-now in an internal function cc/--days-until that generates a formatted string of the days until a target date.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
From there we can then start defining commands that use cc/--days-until. The command cc/days-until shown below will prompt you with a date picker to enter a date. Note that you can enter a date value (e.g. “Dec 25, 2026”) in the mini-buffer prompt for org-read-date.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Going back to the original motivator for this post, here’s an implementation of days until the next two major U.S. election dates with the command cc/days-until-voting.
1 2 3 4 5 6 7 8 9 10 11 12 | |
The result of M-x cc/days-until-voting as of 8 April 2026 is:
209 days until 2026 midterms, 944 days until 2028 presidential election
It’s so human to want to know how long it’s going to take. Feel free to build your own countdown clocks using the code above. May your journey to whatever you plan be a happy one!
Past Articles
| 7 APR 2026 |
Calming Mouse Interaction in DiredSingle click to open a file in Dired is too twitchy. This post shows how to change it. read more |
| 30 MAR 2026 |
Announcing AnjuAnnouncing Anju, a project to align mouse interactions in Emacs with contemporary (circa 2026) expectations. Now available on MELPA. read more |
| 3 MAR 2026 |
Casual now available on NonGNU ELPACasual is now available on NonGNU ELPA. read more |
| 19 FEB 2026 |
Announcing Casual OrgAt long last, announcing Casual support for Org Mode. read more |
| 10 FEB 2026 |
Deburring Emacs Imenu GUI ConfigurationA bit of tuning to get Imenu GUI configuration working with any derived mode from |
| 7 FEB 2026 |
Using Casual to work with Emacs Registers, Rectangles, and WindowsUse Casual to effectively use Emacs registers, rectangles, and windows on the regular. read more |
| 26 JAN 2026 |
Getting Eshell nth History to WorkOut of the box, Eshell nth history recall is disabled. Here’s how to turn it on. read more |
| 22 JAN 2026 |
Announcing Casual EWWAnnouncing Casual support for EWW, a web browser within Emacs. read more |
| 6 JAN 2026 |
Announcing Casual HTML & CSSAnnouncing Casual support for the HTML and CSS editing modes in Emacs. read more |
Page 1 / 18 >