org-habit: C-u K in agenda toggles display all/today habits

* lisp/org-habit.el (org-habit-toggle-display-in-agenda): New command.
This commit is contained in:
Marco Wahl 2019-03-18 17:01:16 +01:00
parent ee1ec29405
commit 2e92b9abb9
3 changed files with 19 additions and 3 deletions

View File

@ -4187,7 +4187,8 @@ the way habits are displayed in the agenda.
#+vindex: org-habit-show-habits-only-for-today
If non-~nil~, only show habits in today's agenda view. The default
value is ~t~.
value is ~t~. Pressing {{{kbd(C-u K)}}} in the agenda toggles this
variable.
Lastly, pressing {{{kbd(K)}}} in the agenda buffer causes habits to
temporarily be disabled and do not appear at all. Press {{{kbd(K)}}}

View File

@ -152,7 +152,10 @@ LaTeX font locking.
negative value as a valid repeater to shift time stamps in backward
in cloned subtrees. You can give, for example, -3d to shift three
days in the past.
*** Toggle display of all vs. undone scheduled habits conveniently
=<C-u K>= (~org-habit-toggle-display-in-agenda~) in an agenda toggles
the display of all habits to those which are undone and scheduled.
This is a function for convenience.
** New functions
*** ~org-dynamic-block-insert-dblock~
@ -164,6 +167,7 @@ dynamic block in ~org-dynamic-block-alist~.
*** ~org-table-cell-down~
*** ~org-table-cell-left~
*** ~org-table-cell-right~
*** ~org-habit-toggle-display-in-agenda~
** Removed functions
*** ~org-babel-set-current-result-hash~

View File

@ -449,7 +449,18 @@ current time."
(message "Habits turned %s"
(if org-habit-show-habits "on" "off")))
(org-defkey org-agenda-mode-map "K" 'org-habit-toggle-habits)
(defun org-habit-toggle-display-in-agenda (arg)
"Toggle display of habits in agenda.
With ARG toggle display of all vs. undone scheduled habits.
See `org-habit-show-all-today'."
(interactive "P")
(if (not arg)
(org-habit-toggle-habits)
(org-agenda-check-type t 'agenda)
(setq org-habit-show-all-today (not org-habit-show-all-today))
(when org-habit-show-habits (org-agenda-redo))))
(org-defkey org-agenda-mode-map "K" 'org-habit-toggle-display-in-agenda)
(provide 'org-habit)