emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Morgan Smith <Morgan.J.Smith@outlook.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Org Habit fix + new feature
Date: Thu, 13 Oct 2022 11:49:06 +0800	[thread overview]
Message-ID: <87lepktmbx.fsf@localhost> (raw)
In-Reply-To: <DM5PR03MB31638B7ED5E8143EF6635E89C5229@DM5PR03MB3163.namprd03.prod.outlook.com>

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

> ...  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.

Well. Ideally, the habit graph should use current agenda day. Not the
actual current date.

> 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.

Agree.

> 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.

Agree.

>> 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?

Because the last serious change in org-habit was 8 years ago (de51e1aef)
and the main implementation dates back to 13 years ago. org-element has
been introduced 10 years ago. It was simply not a thing when the
original org-habit had been developed.

Similar history goes over clock and log parsing. Nobody bothered to
update them for the new element API.

And notes format is only regexp-based. There is no fixed AST element for
notes. Just hard-coded conventions.

-- 
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	other threads:[~2022-10-13  3:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 16:39 [PATCH] Org Habit fix + new feature Morgan Smith
2022-10-11 20:22 ` Colin Baxter
2022-10-11 21:47   ` Morgan Smith
2022-10-12  6:08     ` Colin Baxter
2022-10-12  6:29 ` Ihor Radchenko
2022-10-12 13:15   ` Morgan Smith
2022-10-13  3:49     ` Ihor Radchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lepktmbx.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=Morgan.J.Smith@outlook.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).