Skip to content

⏲️ Effortlessly clock in/out of org-mode tasks, with completion and persistent history

Notifications You must be signed in to change notification settings

unhammer/org-mru-clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 

Repository files navigation

org-mru-clock

https://melpa.org/packages/org-mru-clock-badge.svg https://stable.melpa.org/packages/org-mru-clock-badge.svg

Do you often clock in to many different little tasks? Are you annoyed that you can’t just clock in to one of your most recent tasks after restarting Emacs?

org-mru-clock.gif

The function org-mru-clock-in from this package will pre-fill your clock history with clocks from your agenda files (and other open org files) so you can clock in to your most recent clocks regardless of whether you just started Emacs or have had it running for decades. Tasks are sorted by recency, and uses completing-read for quick selection. This makes it a nice replacement for org-clock-in-last.

It uses completing-read-function (overridable with org-mru-clock-completing-read) on org-mru-clock-in to make clocking in faster. If you set that to ivy-completing-read, you can hit M-o g to visit to the task heading instead of clocking in (there are also Embark actions if you prefer that – see Usage).

The list is sorted to keep the most recently clocked entry first, although if the entry at point is an org-mode heading (in an org file or the agenda), then that will be pushed to the top of the list (you can turn off this behaviour by setting org-mru-clock-include-entry-at-point to nil).

You can also use org-mru-clock-select-recent-task as a replacement for org-clock-select-task, again with pre-filled history.

You may also capture new tasks on the fly if your search text didn’t match anything – try C-h v org-mru-clock-capture-if-no-match RET.

Installation

MELPA

If you use MELPA, you can just do M-x list-packages, find org-mru-clock in the list and hit i x.

Manual

Just put org-mru-clock.el somewhere in load-path.

Usage

Manual, loading on startup:

To use, require and bind whatever keys you prefer to the interactive functions:

(require 'org-mru-clock)
(global-set-key (kbd "C-c C-x i") #'org-mru-clock-in)
(global-set-key (kbd "C-c C-x C-j") #'org-mru-clock-select-recent-task)

Maybe trade some initial slowness for more tasks cached:

(setq org-mru-clock-how-many 100)

But don’t set it higher than the actual number of tasks; then it’ll always try (and fail) to fill up the history cache!

If you want to use ivy for org-mru-clock-in:

(setq org-mru-clock-completing-read #'ivy-completing-read)

If you use the embark package, you can add actions with:

(add-hook 'minibuffer-setup-hook #'org-mru-clock-embark-minibuffer-hook)

With use-package

If you prefer use-package, the above settings would be:

(use-package org-mru-clock
  :ensure t
  :bind* (("C-c C-x i" . org-mru-clock-in)
          ("C-c C-x C-j" . org-mru-clock-select-recent-task))
  :config
  (setq org-mru-clock-how-many 100
        org-mru-clock-completing-read #'ivy-completing-read)
  (add-hook 'minibuffer-setup-hook #'org-mru-clock-embark-minibuffer-hook))

Other org-mru-clock settings

If you do

(setq org-mru-clock-keep-formatting t)

then entries will be shown in their org-mode faces, instead of whatever face your org-mru-clock-completing-read function uses by default.

If you do

(setq org-mru-clock-include-entry-at-point nil)

then the entry at point will not be prepended to the start of the list.

By default, all open org-mode files are searched for recent clocks, but you can change this to e.g. only the org-agenda-files with

(setq org-mru-clock-files #'org-agenda-files)

or some other function of your own devising.

You can also exclude clocks by setting org-mru-clock-predicate to e.g. org-entry-is-todo-p (which will exclude DONE tasks) or org-mru-clock-exclude-done-and-archived (which will also exclude those tagged with org-archive-tag).

Related settings from org-clock

You may also be interested in these general org-clock settings (documented in the Org-mode manual):

(setq org-clock-persist t)
(org-clock-persistence-insinuate)

About

⏲️ Effortlessly clock in/out of org-mode tasks, with completion and persistent history

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published