2020-06-15 Emacs, Org-mode, Beeminder and pomodoros

As some of my readers probably know, I am a happy user of Beeminder, and I even wrote my own Emacs- and Org-based Beeminder client.

For some time, I’ve been thinking about somehow incorporating the famous pomodoro technique into my productivity quiver. The problem was, I did know how exactly to do it.

Until today.

Here is my idea. I created a Beeminder goal to have at least four 25-minutes sessions of work per day (I often work in shorter stretches, which is probably not optimal, but I have already learned that not starting small is a path to failure). Of course, the tricky part is making data entry as smooth as possible. Here is the idea that occurred to me today: let’s write some code that will submit a “one” to that goal every time I clock out in org-mode after doing 25 or more minutes of anything. Simple? Yes. Perhaps even too simple, but should do as a proof of concept. The beauty lies in the fact that it took me less than half an hour and about a dozen lines of code to have a working prototype in Elisp:

(require 'beeminder)

(defun tomato-clock-out ()
  "Check if the clock qualifies as a tomato.
This means at least 25 minutes."
  (when (not (string-match " LINE REMOVED$" (or (current-message) ""))) ; hack
    (let ((minutes (org-duration-to-minutes (org-element-property :duration
	  (headline (substring-no-properties (org-get-heading t t t t))))
      (when (>= minutes 25)

(define-minor-mode tomato-mode
  "A global minor mode tracking number of pomodoros with beeminder.el."
  :init-value nil
  :global t
  :lighter " ó"
  (if tomato-mode
      (add-hook 'org-clock-out-hook #'tomato-clock-out) 
    (remove-hook 'org-clock-out-hook #'tomato-clock-out)))

Let me make a few comments here. The hack with LINE REMOVED is necessary because I have org-clock-out-remove-zero-time-clocks set to t. The code requires my Emacs Beeminder client, but it would be very easy to adapt it to something else. The global mode is an icing on the cake (notice the lighter;-)).

As usual, Emacs proves to be an exellent platform to implement simple but useful tools.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode