emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Org Habit fix + new feature


From: Ihor Radchenko
Subject: Re: [PATCH] Org Habit fix + new feature
Date: Wed, 12 Oct 2022 14:29:03 +0800

Morgan Smith <Morgan.J.Smith@outlook.com> writes:

> The second patch allows a habit to be considered done if time was logged
> to it.  Imagine you have an org habit like shaving.  Chances are, if you
> spend time doing it, it's done.  I like to set LOGGING to nil for these
> kinds of habits since it's redundant to have all those state changes
> that tell me exactly what the logbook already tells me.

I am not against such feature. However, using clocking will break an
assumption that a single log record corresponds to a single habit
completion. This assumption is implied across org-habit code.  

> From cc16dd6a8c59312a75b8e25669a7e4eb3d9f9ef4 Mon Sep 17 00:00:00 2001
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
> Date: Tue, 11 Oct 2022 11:44:26 -0400
> Subject: [PATCH 1/2] lisp/org-habit.el: Use time as a history cutoff point
>
> * lisp/org-habit.el (org-habit-parse-todo): Use time as a cutoff point
> instead of using a count.
>
> This allows viewing the full history of habits that are completed
> multiple times a day.  Previously we would miss some days and show an
> incorrect history

There is currently nothing in the manual or function docstring that
suggest supporting habits that are repeated multiple times a day.

5.3.3 Tracking your habits section of the manual says:

       What’s really useful about habits is that they are displayed along
    with a consistency graph, to show how consistent you’ve been at getting
    that task done in the past.  This graph shows every day that the task
    was done over the past three weeks, with colors for each day.  The
    colors used are:

Explicitly saying that each symbol in the graph corresponds to a single
day.

Further, org-habit-preceding-days and org-habit-following-days are
explicitly talking about days, not repetitions.

> -      (let* ((maxdays (+ org-habit-preceding-days org-habit-following-days))
> +      (let* ((firstday (- (org-today) org-habit-preceding-days))

What about org-habit-following-days? Why did you throw it away?
Also, (org-today) does not consider org-extend-today-until. (see
org-habit-insert-consistency-graphs).

>            (re (format
> -               "^[ \t]*-[ \t]+\\(?:State \"%s\".*%s%s\\)"
> +               "^[ \t]*-[ \t]+\\(?:State \"%s\".*%s%s\\)%s"
>                 (regexp-opt org-done-keywords)
>                 org-ts-regexp-inactive
>                 (let ((value (cdr (assq 'done org-log-note-headings))))
> @@ -233,15 +238,20 @@ This list represents a \"habit\" for the rest of this 
> module."
>                                ("%t" . ,org-ts-regexp-inactive)
>                                ("%T" . ,org-ts-regexp)
>                                ("%u" . ".*?")
> -                              ("%U" . ".*?")))))))))
> +                              ("%U" . ".*?"))))))
> +                  (if org-habit-clock-completes-habit
> +                      (concat
> +                       "\\|^" org-clock-string ".*\\]--\\(\\[[^]]+\\]\\)")
> +                    ""))))

This logic will fail for non-default combinations of org-log-into-drawer
+ org-clock-into-drawer + org-log-states-order-reversed.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]