0

I've posted before on using Brent Hansen's amazing org setup. This time around, I'm specifically having a problem with getting org-mode to display my habits.

I had to nuke my emacs and start from scratch recently, so debugging is hard.

I am quite certain that I have habit mode enabled since:

  1. I have enabled in my .emacs (see below)

;; Enable habit tracking (setq org-modules (quote (org-habit)))

; position the habit graph on the agenda to the right of the default (setq org-habit-graph-column 50)

(run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))

  1. My capture template for habits, seems to set up to include everything needed:

    ("h" "Habit" entry (file "~/Dropbox/org-new/refile.org") "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"%<<%Y-%m-%d %a .+1d/3d>>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n")

  2. I have an additional set of properties in my Top Level Header for habits that reads:

    * Habits :PROPERTIES: :LOGGING: DONE(!) :ARCHIVE: %s_archive::* Habits :END:

  3. When I run the agenda, I see (Org-Agenda Day Ddl Grid Habit Wrap) in the Mode line

Despite that, my habits do not show up, nor does a habit graph, when I run the agenda. I've trawled everything I can to try and solve this and I'm now at my wit's end. Any help would be greatly appreciated!

krishnan
  • 671
  • 1
  • 10
  • 21

1 Answers1

2

You need to add a :STYLE: property with the value habit to your habits:

 ** TODO Shave
    SCHEDULED: <2009-10-17 Sat .+2d/4d>
    - State "DONE"       from "TODO"       [2009-10-15 Thu]
    - State "DONE"       from "TODO"       [2009-10-12 Mon]
    - State "DONE"       from "TODO"       [2009-10-10 Sat]
    - State "DONE"       from "TODO"       [2009-10-04 Sun]
    - State "DONE"       from "TODO"       [2009-10-02 Fri]
    - State "DONE"       from "TODO"       [2009-09-29 Tue]
    - State "DONE"       from "TODO"       [2009-09-25 Fri]
    - State "DONE"       from "TODO"       [2009-09-19 Sat]
    - State "DONE"       from "TODO"       [2009-09-16 Wed]
    - State "DONE"       from "TODO"       [2009-09-12 Sat]
    :PROPERTIES:
    :STYLE:    habit
    :LAST_REPEAT: [2009-10-19 Mon 00:36]
    :END:

See Tracking your habits.

EDIT: While the STYLE:habit property is necessary, that isn't the problem in this case (as discussed in the comments). However, it might well be that the order of the elements in the headline is the problem. Running org-lint on the following example:

* NEXT Exercise
  [2017-07-16 Sun 19:36]
  [[file:~/Dropbox/org-new/todo.org::*Write][Write]]
  SCHEDULED: <2017-07-16 Sun .+1d/2d>
  :PROPERTIES:
    :STYLE: habit
    :REPEAT_TO_STATE: NEXT
  :END:

I get

 3 low   Link to non-existent local file "~/Dropbox/org-new/todo.org"
 4 low   Misplaced planning info line
 5 high  Incorrect location for PROPERTIES drawer

If I reorg the file a bit to this:

* NEXT Exercise
  SCHEDULED: <2017-07-16 Sun .+1d/2d>
  :PROPERTIES:
    :STYLE: habit
    :REPEAT_TO_STATE: NEXT
  :END:
 [2017-07-16 Sun 19:36]
 [[file:~/Dropbox/org-new/todo.org::*Write][Write]]

then the high priority warning disappears. I don't know whether that will make habits work, but I'm willing to bet that it would.

The manual states:

When they are associated with a single entry or with a tree they need to be inserted into a special drawer (see Drawers) with the name PROPERTIES, which has to be located right below a headline, and its planning line (see Deadlines and scheduling) when applicable.

NickD
  • 5,937
  • 1
  • 21
  • 38
  • Hey @Nick, I've done that. If you see my capture template above, it imposes the style. For example, here is one habit with the `:STYLE:` property clearly defined. `* NEXT Exercise [2017-07-16 Sun 19:36] [[file:~/Dropbox/org-new/todo.org::*Write][Write]] SCHEDULED: <2017-07-16 Sun .+1d/2d> :PROPERTIES: :STYLE: habit :REPEAT_TO_STATE: NEXT :END: ` Sorry! The comment box doesn't appear to format newlines right! – krishnan Aug 14 '17 at 12:36
  • Oops - sorry. I missed that. Where exactly is the first newline in your entry? org 9 has imposed some restrictions on what the structure of an entry should look like. Try running `org-lint` on the file and see if there are any complaints. – NickD Aug 14 '17 at 16:48
  • Now that I took another look at your template, I think that it is indeed the structure that is tripping you up (but I haven' tried it out, so take it with the appropriate grain of salt). – NickD Aug 14 '17 at 16:50
  • you are absolutely right! Thank you so much. This solves the problem!! – krishnan Aug 25 '17 at 12:15