Thinking about time travel with the Emacs text editor, Org Mode, and backups
| emacs, orgSometimes I just need to rewind 15 minutes. That's the length of A+'s recess at virtual school, which she does at home. At recess, she often likes to get hugs and sometimes a snack. If I'm working on something that requires sustained thought, like code or a blog post, I can't hold those thoughts in my head for that long while cheerfully listening to A+ share the trivia she's read on the Stardew Valley wiki. If I try to keep my train of thought, I get grumpy. I'd rather get better at time travel instead. Naturally, this calls for Emacs.
For people who are unfamiliar with Emacs or Org Mode
GNU Emacs is a highly customizable program for editing text, writing code, and doing mostly whatever people want to get it to do. Org Mode is a package (or ecosystem of packages, really) that modifies GNU Emacs to make it easier to take notes, plan tasks, export documents, and so on. If you're not into Emacs yet, this post might be a little technical, but maybe there are ways to translate some of the ideas to things you're using.
What was I doing again?
Sometimes recess totally resets my brain and I
can't even think of what I was just working on. To
make it easier to hit the ground running, I try to
make a habit of creating a task in Org Mode before
I start working on it. Or, more realistically,
halfway through, when I realize I have to first do
another thing, so then I jot down a quick task
for the work I was previously doing and another
task for the tangent I'm about to go on. That way,
I can quickly check my notes to see what I was
doing. org-capture
(which I've bound to C-c r
)
is handy for that. I have a template (t
) that
creates a timestamped TODO that links to the
context I created it in (files, note headings,
etc.) and saves it to my inbox file. Then I can
jump to my inbox file with a keyboard shortcut and
look at what I need to get back to doing.
Sometimes I vaguely remember that I've already
created a task for this before and I can find it
with C-u C-c C-w
(org-refile
). When
org-refile
is called with a universal prefix
argument (C-u
), it will prompt for a heading in
org-refile-targets
and jump to it. I have it set
to complete the outline path, so I can try to find
things by project. Failing that, I might have a
quick rummage in my inbox. I usually don't
remember the exact words I used in the the task
title, though. Maybe someday I'll get the hang of
org-ql or p-search (Emacsconf talk on p-search),
resurrect the Remembrance Agent so that it can
continuously do bag-of-words matching, or use
embeddings to find semantically similar tasks and
notes. In the meantime, capturing the task is more
important than avoiding duplicates. I can find and
clean up duplicates later on.
All of that is moot when I'm away from my computer, which is most of the time. My phone is pretty handy for quick notes, though. I use Orgzly Revived to capture a quick note in my inbox. This gets synchronized with my Org Mode notes using Syncthing.
Hmm, I gotta do this first…
Often the interruption doesn't even come from
outside, but from my brain's endless stream of
interesting ideas. Some of those ideas can be
saved as tasks to work on eventually, but
sometimes I need to pause my current task and work
on the new idea. I have a template for an
interrupting task (i
) that automatically clocks
out of the previous task and clocks into the new
one.
My template for interrupting tasks
This is the entry in my org-capture-templates.
("i" "Interrupting task" entry
(file ,my-org-inbox-file)
"* STARTED %^{Task}\n:PROPERTIES:\n:CREATED: %U\n:END:\n%a\n"
:clock-in :clock-resume
:prepend t)
Okay, that's done, what was I doing before?
If I clock into tasks, I can use org-clock-goto
along with the C-u
universal prefix (C-u C-c
C-x C-j
) to see a list of recently-clocked-in
tasks. This is great for "popping the stack,"
which is how I think of backtracking once I
finished an interrupting task.
I usually forget to clock out. That's okay. I'm not looking for precise total times, just breadcrumbs.
… What was I thinking?
Sometimes a few keywords aren't enough to jog my memory. Whenever I think, "Ah, this is easy, I don't need to take notes," I inevitably regret it. Sometimes I realize I have to re-do my thinking fifteen minutes later, when singing 4-Town songs with A+ has pushed those thoughts out of my brain. Sometimes I have to re-do my thinking several months later, which is even harder.
Notes are super-helpful. I love the way Org Mode lets me write notes, paste in hyperlinks, add snippets of code, save the results of my explorations, include my sketches, and even export them as blog posts or documents to share.
Sometimes I have to go back farther into the past
It can take me months or even years before I can circle back to a project or idea. It can be hard to reconstruct my thinking after a lot of time has passed, so it's good to write down as much as possible. Taking notes feels slower than just plunging ahead, but they help me travel back in time to try to remember.
This really gets hammered in when I run into things I've forgotten, like when I dusted off my time-tracking code so I could make some changes. In the four years that elapsed between Aug 2020 (my last change) and Oct 2024 (when I decided to upgrade it to the latest version of Rails), I'd forgotten how to even run a development version of my code. Whoops. I ended up taking more notes along the way.
I try to keep project-related notes as close to the project files as possible, like a README.org in the project directory. Sometimes I don't even remember what the project is called. I try to keep another file that indexes things on my computer as well as things in real life.
Sometimes I know I wrote tasks or notes down before but I can't remember the exact words I used for them. I'm curious about whether embeddings might help me find those things again. So far it's been okay to just add a new task or note, and then periodically clean up entries that are no longer needed.
Going sideways
Sometimes I want to visit alternate timelines, trying different ways to do something. I really like the way undo works in Emacs. It's different from most programs. Emacs keeps the things you undo/redo.
Let's say I start writing a paragraph or a piece of code. I change my mind about something. Maybe I undo, maybe I cut, maybe I delete. I write again. I change my mind again. The first way was better, maybe. I can go back to that, step through any of the intermediate changes, consider the other version again. It's not lost.
Actually navigating the Emacs undo history can be tricky. I like using the vundo package for that. It shows a compact view of the different branches of this timeline so that I can easily jump between them or compare them.
If I'm working on something more complicated, like code, I might make changes over several sessions. This is where version control is handy. I like using the Git version control system, especially with the Magit package. I can commit versions of the files manually along with a quick note about what I changed or what I'm trying. This allows me to easily reset to a certain point.
Sometimes I'm good about picking the right point to commit: I've made decent progress and things are working. Sometimes I realize only later on that I probably should have saved a commit a little while ago, and now I'm halfway through another idea that I'm not going to have time to finish and that leaves my project in a non-working state. In that situation, sometimes I'll use the visual undo provided by the vundo package to go backwards to a version that looks about right, save that file, commit it with a quick note, and then go forward in time again.
Saving revisions in Git makes it much easier to go
backwards in time even if I've restarted my
computer. magit-blame
and vc-annotate
give me
slightly different views showing me the changes in
a file. They don't show me information on deleted
sections, though. For that, I can use the
magit-diff
command to compare versions.
Sometimes it's easier to flip through the history
of a single file with git-timemachine.
Git lets me name different experimental timelines (branches) and logically group changes together. It means I don't have to worry so much about messing up a working file, since I can travel back in time to that version. It also means I can easily compare them to see what I've changed so far.
In addition to using version control for various
projects, I also save backup files to a separate
directory by setting my backup-directory-alist
to (("." . "~/.config/emacs/backups"))
. Disk
space is cheap; might as well keep all the
backups. I sometimes manually go into this
directory to find older versions of things. It
occurs to me that it might be good to flip through
the backups in the same way that git-time-machine
makes it easy to flip through git revisions. I'm
trying out lewang/backup-walker, which shows the
incremental diffs between versions. It was last
updated 12 years ago(!), but can easily be dusted
off to work with Emacs 30 by defining some
functions that it's looking for. Here's my config
snippet:
(use-package backup-walker
:vc (:url "https://github.com/lewang/backup-walker")
:init
(defalias 'string-to-int 'string-to-number)
(defalias 'display-buffer-other-window 'display-buffer))
Into the future
It's not all about going back to the past. Sometimes I want to plan ahead: tasks that I want to schedule for a certain date, pre-mortems to help me make decisions, gifts for my future self. I use Google Calendar for appointments and other things I might want to share with W- for planning, but there are lots of other things that aren't tied to a specific time and date. The agenda feature of Org Mode is handy for scheduling things and moving them around.
Scheduled tasks don't work out so well if my agenda gets cluttered by things I ignore, so if I find myself procrastinating something a lot, I think about whether I really want to do whatever it is I've written down.
Some notes aren't associated with specific dates, but with other events that might happen. I have an Org Mode outline with various subheadings under "In case of…", although I often forget to check these or have a hard time finding them again. Maybe someday I can write a script that analyzes the words I use in my journal entries or tasks and finds the notes that approximately match those keywords.
Things I want to try
Thinking out loud more might be worth
experimenting with, since I can do that while I'm
working in a different file. I've used my audio
recorder to record braindumps and I have a
workflow for transcribing those with OpenAI
Whisper. I think it would be even more useful to
have an org-capture equivalent so that I can
capture the thought by audio, save the recording
in case there are recognition errors (highly
likely because of the technical terms), and save
the context. Or maybe an even neater interface
that keeps an ear out for keywords, executes
commands based on them, and saves the rest as
notes? whisper-ctranslate2 has a live_transcribe
option that works reasonably well after a short
delay, and maybe I can use a process filter to
pull the information out or write a custom Python
script.
I appreciate how working with plain text can help me jump backward or forward in time. I'm looking forward to seeing how this can be even better!
This post was inspired by Emacs Carnival 2025-06: Take Two • Christian Tietze and IndieWeb Carnival: Take Two. Check those out for related blog posts!
This is, in fact, my second take on the topic. =) Here's my first one: Making and re-making: fabric is tuition