From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uPSZIsaKR2NVMAEAbAwnHQ (envelope-from ) for ; Thu, 13 Oct 2022 05:49:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cI6sIsaKR2MI0AAA9RJhRA (envelope-from ) for ; Thu, 13 Oct 2022 05:49:26 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 276C385BA for ; Thu, 13 Oct 2022 05:49:26 +0200 (CEST) Received: from localhost ([::1]:57182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oipDo-0005oL-HZ for larch@yhetil.org; Wed, 12 Oct 2022 23:49:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oipCq-0005mo-Mp for emacs-orgmode@gnu.org; Wed, 12 Oct 2022 23:48:24 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:36555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oipCn-0005kB-Qm for emacs-orgmode@gnu.org; Wed, 12 Oct 2022 23:48:24 -0400 Received: by mail-pl1-x633.google.com with SMTP id c24so732052plo.3 for ; Wed, 12 Oct 2022 20:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=80yjt0jB/cDtWB2rdgSFIhnPZAMNzkgWVPMn/og27Fw=; b=Ildc6yRBkBVMVzTSub9EV59cABP0it4sKwVwOm0hIilAUZ0Wk7gy9eEofjtai7kZFc z3dso8Nq/OdXdIUygBc0U1jB36MLcJ3+aoFSzooKVHOc8klZVVu3dwH8rXY6x4+Jpe2p iP8scZYbJ2jvgNUDpEd+k4g38AJnbH1DZWi+UpQZaWSWxhXCTOEl64MH+WHN2/6N90Tw LBmBG0IbOJJDkOIQZERcTc0x4EgTgvTE+/PmnMiXNjuyZCo9PE7WOuB5rBgUa0BccBFX dT3ssEEWuCEXy9l80Myp5hlLqPs46A9OI8PnF8IpTDnEp541P8jpFG639HzcudFoTeQI A5tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=80yjt0jB/cDtWB2rdgSFIhnPZAMNzkgWVPMn/og27Fw=; b=vCEwWyVgnSegu9yZ7Q2cVVlTE2sZ5LP0K1lJd2s0ox43ls33CIxGTOp2TfvmhoyZdt vVpVJWhCIZKVRz5+xUuyYFRjO0TJFuf9kSIH9jzsQ4Tvfwayj+CLmAdqq0304av8+fhP sTfXHJCzNk9z5RtJdSCCzhTvJoQtro4HYJGHz88Dctv1W1yXJvbDiNs6k2CFlQydBYbQ fPHWEHFroziKyyxj2pz0KEmCcMn/iNu6LMkdYA7Q2hieN+8P1oDsCRFMR/kgxBfpIfcd vZENa7W1WMkjAHSBQ5/fxKp2Hy7LdcvIiGqLwLIvCimJIMpWgMlVNDYXHsZif/1vQO66 espw== X-Gm-Message-State: ACrzQf1tG7RHg/R/+dq0piIEJFYtofgbUs/Um0Px6cVnUdMncQHJ1Xso doHILEOO1dS6KI63bWANEl0= X-Google-Smtp-Source: AMsMyM6rV8K+YJ2cPqzpTbRmfXKs8CEFC4Prgrc01H811GD/jTv8zg+txKZoWxRuKZ4+9pqAQcBd3A== X-Received: by 2002:a17:903:41cc:b0:183:5a22:c633 with SMTP id u12-20020a17090341cc00b001835a22c633mr14420757ple.164.1665632898781; Wed, 12 Oct 2022 20:48:18 -0700 (PDT) Received: from localhost ([2409:8970:af2:32f:6c23:3ad5:f37d:541b]) by smtp.gmail.com with ESMTPSA id t10-20020a65408a000000b00451f4071151sm10328276pgp.65.2022.10.12.20.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:48:18 -0700 (PDT) From: Ihor Radchenko To: Morgan Smith Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Org Habit fix + new feature In-Reply-To: References: <87leplsggg.fsf@localhost> Date: Thu, 13 Oct 2022 11:49:06 +0800 Message-ID: <87lepktmbx.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=yantar92@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665632966; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=80yjt0jB/cDtWB2rdgSFIhnPZAMNzkgWVPMn/og27Fw=; b=Q9JF+0Wx5i0i9YGRrm78YF5pDQTYIx/XsTXEgLnv1d7l27jcq2fS0MS8CUiGSTcEN2bNEn ZcWQYn+MJvOCxNflvy/W4mk6owxe/ngxDP6uxcQlhe3T9ZQ+rJlFdJYoKQ1a/zypD/E7ML 2DlbtnWOaQBEZ2vaIY1NpWoyx/38ZAFlt5eqdC3qBWj/9rK6GPqh0oZ2TWxhMhNfWTcEB+ 9zUV9sLBE+ifz/quBhiSeLxrK6t1VdC/ti46dFa5McRBs9honMZRgwG1yDVvj5XxpnbhH8 Cd2pb+2oC1n/3K1DN2Zh0JzrvqCKi+4Bsg3E8DYMSOQu3iCfLIXBctSuxF7QyA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665632966; a=rsa-sha256; cv=none; b=aKfzrHq71jwkAWVzJnVyJV/Wmk4v+KK3IyAaVXM25aJI+Uj/qv5rxyBRJuThjYg2Aria5t DOEEIpw9L7louDtQzLRgLAo3eW+r4+4bPMBjPgs24RQ7g/aehttx8hf7mzTkYy7fipxpa1 LDvUD5aXeaGhUL8vgctnsVI+kdH7KSZAzlYDZi3m0+u4QEqLcg8TUbUvWaGPFWeRpiv3x4 qm0g35msiKW5HTyOPW/TRfEOvX7RZupv2aGDhYpVvyvJ81HwdbvjYpOtHrShJJq+opUVhk /7yb7g80yQR5HnmR2VIgW6xikpqaDlBOX4s6c/DQrhqMIYeHYjoPqT8sAUKkIA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ildc6yRB; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.20 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ildc6yRB; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 276C385BA X-Spam-Score: -3.20 X-Migadu-Scanner: scn0.migadu.com X-TUID: v9VtNvV9Tl30 Morgan Smith 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 . Support Org development at , or support my work at