Ihor Radchenko <yanta...@gmail.com> writes: > > 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. > Oh that's a good point. I'll have to go back through the code and see if that's an issue.
As for your comments on the first patch, let me explain where the current logic falls short. Imagine you complete a habit multiple times in a day because you're using org wrong (yep this also violates that previous thing that I gotta look into but let's not worry about that for now). The current logic simply looks at the previous '(+ org-habit-preceding-days org-habit-following-days)' log records which by default would be 28. First of all, why are we looking into the future at all? I don't think the habits graph currently supports looking at it from the perspective of a different day and I think marking things as complete in the future is pretty odd. Second of all, if we use org wrong, then we will start loosing days at the beginning of the graph if we have more then 28 log records in our period. Now my patch calculates the first day of the graph and simply looks at all log records before that date. This is more robust if we want to use org wrong. Also it's more intuitive I think. In many cases I think it will also be a performance boost since then we likely won't loop the full 28 times. Furthermore, this method would support looking at the habits graph from the perspective of a different day (which blindly looping 28 times does not). This patch does not do a good job at adding support for repetitions. The graph and logic still works in days, not repetitions. It simply makes the current code more robust. > Also, (org-today) does not consider org-extend-today-until. (see > org-habit-insert-consistency-graphs). Thanks for catching that! > > This logic will fail for non-default combinations of org-log-into-drawer > + org-clock-into-drawer + org-log-states-order-reversed. Well shoot. That's a bummer. So why are we using a regex here anyways? It feels not super robust. Don't we have an AST we could use instead? Also even if we do want to use regex, pulling out log records and clock records seems like a pretty common thing to do that should be in a core library function right? Thanks for the review! I appreciate your feedback Morgan