18

I want to track habits using org-mode. For example, I want to do exercise 3 times every week. Is there a way to schedule 3 times a task every week irrespective of the date in org-mode?

Mat
  • 202,337
  • 40
  • 393
  • 406
18bytes
  • 5,951
  • 7
  • 42
  • 69

3 Answers3

27

You should be able to more or less do that using org habit tracking (See: Org-Habits).

To load org-habits you would need to add it to org-modules

(add-to-list 'org-modules "org-habit")

Then:

  1. Use C-c C-s to set SCHEDULED.
  2. Use C-c C-t to set your exercise TODO.
  3. Use C-c C-x p to have the STYLE Property habit (add in any other properties as desired as well).

Now the lines like this should have be appended after the title:

:PROPERTIES:
:STYLE: habit
:END:

A single habit should suffice, it will not be exactly 3 times per week, but over time it will average out to such. If you use a scheduled repeater that is .+2d/3d you will be prompted to perform the habit no more often than every second day, and no less often than every 3. (This averages out to 2.9 times per week if you continue it long enough. Over 6 weeks (42 days) you would complete it at least 14 times, at most 21, or 17.5 on average. 18 times in 6 weeks would be 3x per week).

Your final habit should look something like this initially, as you complete it DONE logging will be added in and the last-repeat will be kept track of as a property:

** TODO Exercise
SCHEDULED: <2012-01-06 Fri .+2d/3d>
:PROPERTIES:
:STYLE: habit
:END:

Note: If you get the error Symbol's value as variable is void: org-modules when trying to load the org-habit module, you might want to try the following instead:

(require 'org)
(require 'org-install)
(add-to-list 'org-modules "org-habit")
kuanyui
  • 782
  • 13
  • 23
Jonathan Leech-Pepin
  • 7,684
  • 2
  • 29
  • 45
  • If specific timing in the week is important, then three habits repeating weekly (+1w) will also work, but the habit tracking is less clear. Perhaps sub tasks? I'll have to try it – mike May 03 '15 at 21:03
  • `(add-to-list 'org-modules 'org-habit)` for me – Josh.F Aug 23 '17 at 22:05
0

You can use a timestamp with repeater interval as described in the manual.

 A timestamp may contain a _repeater interval_, indicating that it
 applies not only on the given date, but again and again after a
 certain interval of N days (d), weeks (w), months (m), or years
 (y).  The following will show up in the agenda every Wednesday:

      * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
Daimrod
  • 4,902
  • 23
  • 25
0

I can't see any way to do this with one entry. The way I do similar things is to create a special TODO sequence for is, say (sequence ('HABIT' '|' 'CHECK')) with setq org-todo-keywords

Then simply write three entries, each on a week repeat

* HABIT Monday workout
  DEADLINE: <2012-01-09 Mon +1w>
* HABIT Wednessday workout
  DEADLINE: <2012-01-11 Wed +1w>
* HABIT Friday workout
  DEADLINE: <2012-01-06 Fri +1w>

It's not that clean, but it works.

Vernon
  • 2,703
  • 2
  • 24
  • 30
  • I understand the above is not independent of date. I guess the easiest way to achieve that is to use [TODO dependencies](http://orgmode.org/manual/TODO-dependencies.html). – Vernon Jan 06 '12 at 13:04