2

I set up habits in org mode and using C-k to toggle the habits on/off in the normal agenda is working fine.

However, in my custom agenda (taken from Bernt Hansen GTD implementation link) I get the following error when using C-k:

Debugger entered--Lisp error: (error "Not allowed in tags-type agenda buffers")
signal(error ("Not allowed in tags-type agenda buffers"))
error("Not allowed in %s-type agenda buffers" tags)
org-agenda-check-type(t agenda)
org-habit-toggle-habits()
call-interactively(org-habit-toggle-habits nil nil)
command-execute(org-habit-toggle-habits)

The same is true for changing week and day view:

Debugger entered--Lisp error: (error "Not allowed in tags-type agenda buffers")
signal(error ("Not allowed in tags-type agenda buffers"))
error("Not allowed in %s-type agenda buffers" tags)
org-agenda-check-type(t agenda)
org-agenda-change-time-span(week nil)
org-agenda-week-view(nil)
call-interactively(org-agenda-week-view nil nil)
command-execute(org-agenda-week-view)

Any hints on how to toggle habits in the custom agenda? Or why is toggling not possible in tags-type agendas?

By the way I am using spacemacs 0.105.21 (emacs 24.5.1)


The solution is to change (agenda "" nil) to (agenda ""). Here is a part of the custom agenda:

(setq org-agenda-custom-commands
      (quote (("N" "Notes" tags "NOTE"
               ((org-agenda-overriding-header "Notes")
                (org-tags-match-list-sublevels t)))
              ("h" "Habits" tags-todo "STYLE=\"habit\""
               ((org-agenda-overriding-header "Habits")
                (org-agenda-sorting-strategy
                 '(todo-state-down effort-up category-keep))))
              (" " "Agenda"
               ((agenda "")      ;; delete nil
                (tags "REFILE"
                      ((org-agenda-overriding-header "Tasks to Refile")
                       (org-tags-match-list-sublevels nil)))
                (tags-todo "-CANCELLED/!"
                           ((org-agenda-overriding-header "Stuck Projects")
                            (org-agenda-skip-function 'bh/skip-non-stuck-projects)
                            (org-agenda-sorting-strategy
                             '(category-keep))))
...

Thanks to @elethan

1

If your custom agenda view does not have an agenda portion, you will not be able to toggle habits on and off from that view. One of the first things that the function org-habit-toggle-habits (the command you are invoking with C-k, but which is just K for me) does before actually toggling habits, is the following check:

(org-agenda-check-type t 'agenda)

If the agenda type is anything other than agenda, e.g., if it is a tags-based agenda, it will raise the error that you are seeing. I am not sure if there is a way to get around this, or if you would want to.

However, if you add an agenda portion to your custom agenda view, all you need to do is make sure point is in that part of the view, and then org-habit-toggle-habits should work as expected.

  • Can you explain a bit more what the agenda portion means? And what do you mean by: "make sure point is in that part of the view"? – evolved Aug 15 '16 at 16:25
  • Thanks to your hint, I found the line in the custom agenda: (agenda "" nil). Changing this to (agenda "")solves the issue and C-k or just K when using emacs instead of spacemacs, works. Also switching between week and day view. – evolved Aug 15 '16 at 16:27
  • Do you know what the additional nil means in the mentioned line? – evolved Aug 15 '16 at 16:28
  • @evolved honestly, I am not sure what the nil or the "" means in (agenda "" nil). There is decent documentation on custom org-agenda commands, but I haven't been able to find an explanation of this particular part. I just know that you can add an agenda to your custom agenda view by adding (agenda ""), which is what I meant by "add an agenda portion to your custom agenda view". I will try to clean up my answer so that it is a little clearer for future readers. Glad you got it working! – elethan Aug 15 '16 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.