2025-09-01 Differentiating between C-c C-c and C-c C-k

Some of the habits I use Beeminder for are maintaining a journal and weighing myself. The way I do these things is that I have a few capture templates with a nonempty :after-finalize property set to a lambda which sends a datapoint to Beeminder.

The problem is, it also sends its datapoint if I press C-c C-k, effectively canceling the entry. How to make it not do so?

It turns out that the answer is pretty simple (if a little bit ugly). There is a (special, and hence global) variable called org-note-abort which is set to t whenever the user presses C-c C-k in circumstances like typing in a captured thing. This means that the only thing I need to do is to wrap the contents of my lambda in (unless org-note-abort ...).

Something worth remembering is that this of course only works in Org mode. For example, Magit’s C-c C-c and C-c C-k are implemented differently, and to achieve a similar effect there you’d need to check the hooks in the with-editor package.

That’s it for today – a niche tip for sure, but maybe someone will find it useful!

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode