2023-03-20 Manually entering clocking data

As I alluded many times in the past, I use Org mode’s clocking feature almost all the time. However, there are times I don’t. One of such cases is a rare situation when I don’t have access to my computer. Since I started commuting using public transport, I do some reading in a streetcar or bus. When I get to my laptop again, I want to update my clocking data. How to do that?

One way is to use one of the many Org mode mobile solutions. I’ve been looking at Organice for some time. There is, however, one thing that stops me from using it – I am not sure if I really want to have a lot of my private (maybe even a bit sensitive) data on a mobile device, which can be easily lost or stolen. (This really happens. However stupid it sounds, I did lose my mobile phone once, many years ago. And a second time a few weeks ago. And my wife had her phone stolen.) Also, I do not need to clock in/out without access to my computer very often, so for now a manual solution will do.

(defun org-clock-enter-manually (begin end)
  "Enter a clock item manually."
  (interactive (list (org-read-date t t) (org-read-date t t)))
  (save-excursion
    (org-clock-find-position nil)
    (insert-before-markers-and-inherit "\n")
    (backward-char 1)
    (insert-and-inherit org-clock-string " ")
    (org-insert-time-stamp begin t t)
    (org-insert-time-stamp end t t "--")
    (org-evaluate-time-range t)
    (beeminder-org-submit-clock-at-point)))

This is an extremely simplistic code – notice the boring, uniform indentation, which means it doesn’t even need any kind of flow control like loops or conditionals. It just reads the begin and end time, puts it in the suitable place (using function calls I found looking at org-clock-in source code), computes the difference between the two points in time, and finally sends these data to Beeminder.

And that’s it. Until I find a satisfying automated solution (maybe just have the parts of my Org files I really need in Organice?), this will must do.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode