8

Is there a way to make the list of recently clocked-in tasks in org-mode persistent across Emacs restarts and (more importantly) closed buffers? It's annoying having to find the previous task just because I happened to exit a file.

unhammer
  • 1,127
  • 8
  • 22

2 Answers2

5

I made a little package org-mru-clock to solve this.

When I run org-mru-clock-select-recent-task or org-mru-clock-in it finds all recently-clocked-in tasks from org files and stores the top org-mru-clock-how-many in org-history; that takes about 5 seconds, so it doesn't do anything if org-history already has that many entries. This is nicer than saving to disk, since I have the org files version controlled, and the initial 5 second wait is acceptable.

It's compatible with ivy, ido, selectrum or the built-in completion; my init.el has this:

(use-package org-mru-clock
  :ensure t
  :bind* (("<f8>" . org-mru-clock-in))
  :commands (org-mru-clock-in org-mru-clock-select-recent-task)
  :config
  ;; I use embark, this gives me some actions on tasks:
  (add-hook 'minibuffer-setup-hook #'org-mru-clock-embark-minibuffer-hook)
  (setq org-mru-clock-how-many 100))

The ivy interface also happens to make it really easy to switch quickly between recent tasks:

enter image description here

unhammer
  • 1,127
  • 8
  • 22
3

Org-Mode also includes this feature by default. You can set org-clock-persist to 'history to save the clock entry history when closing emacs. Or set it to t to also save the running clock when Emacs is closed. See the manual or the emacs help on org-clock-persist. For this to work you also have to run (org-clock-persistence-insinuate) in your init file.

Dan Drake
  • 503
  • 2
  • 15
fpiper
  • 451
  • 2
  • 2