* Repeating task hourly
@ 2020-07-27 11:30 Kevin Liu
2020-07-27 11:40 ` Kevin Liu
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Liu @ 2020-07-27 11:30 UTC (permalink / raw)
To: emacs-orgmode
According to the manual at
https://orgmode.org/manual/Repeated-tasks.html hourly repeating tasks
are possible, but the code in org-habit.el seems to disagree, explicitly
disallowing an interval <1d:
(error "Habit %s scheduled repeat period is less than 1d" habit-entry))
Is there any way to do this or are the docs out of date?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
2020-07-27 11:30 Repeating task hourly Kevin Liu
@ 2020-07-27 11:40 ` Kevin Liu
2020-07-29 2:29 ` Kyle Meyer
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Liu @ 2020-07-27 11:40 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 162 bytes --]
> Is there any way to do this or are the docs out of date?
I made a few quick changes to org-habit and it works prima facie. Will
continue testing for a bit.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-habit-allow-hourly-repeat.patch --]
[-- Type: text/x-patch, Size: 1619 bytes --]
From e690d7b43143410d5d5af524bb1ff0819feebc24 Mon Sep 17 00:00:00 2001
From: nivekuil <mail@nivekuil.com>
Date: Mon, 27 Jul 2020 04:37:32 -0700
Subject: [PATCH] org-habit: allow hourly repeat
---
lisp/org-habit.el | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index f76f0f213..b9bb729c1 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -157,11 +157,12 @@ means of creating calendar-based reminders."
:group 'org-faces)
(defun org-habit-duration-to-days (ts)
- (if (string-match "\\([0-9]+\\)\\([dwmy]\\)" ts)
+ (if (string-match "\\([0-9]+\\)\\([hdwmy]\\)" ts)
;; lead time is specified.
(floor (* (string-to-number (match-string 1 ts))
(cdr (assoc (match-string 2 ts)
- '(("d" . 1) ("w" . 7)
+ '(("h" . 0.04166666666)
+ ("d" . 1) ("w" . 7)
("m" . 30.4) ("y" . 365.25))))))
(error "Invalid duration string: %s" ts)))
@@ -199,9 +200,7 @@ This list represents a \"habit\" for the rest of this module."
(setq sr-days (org-habit-duration-to-days scheduled-repeat)
sr-type (progn (string-match "[\\.+]?\\+" scheduled-repeat)
(match-string-no-properties 0 scheduled-repeat)))
- (unless (> sr-days 0)
- (error "Habit %s scheduled repeat period is less than 1d" habit-entry))
- (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat)
+ (when (string-match "/\\([0-9]+[hdwmy]\\)" scheduled-repeat)
(setq dr-days (org-habit-duration-to-days
(match-string-no-properties 1 scheduled-repeat)))
(if (<= dr-days sr-days)
--
2.27.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
2020-07-27 11:40 ` Kevin Liu
@ 2020-07-29 2:29 ` Kyle Meyer
2020-07-29 11:06 ` Gustavo Barros
0 siblings, 1 reply; 8+ messages in thread
From: Kyle Meyer @ 2020-07-29 2:29 UTC (permalink / raw)
To: Kevin Liu; +Cc: emacs-orgmode
Kevin Liu writes:
>> Is there any way to do this or are the docs out of date?
>
> I made a few quick changes to org-habit and it works prima facie. Will
> continue testing for a bit.
The hourly repeater came in ec921a2a6 (Support hourly repeat cookies,
2012-04-20), well after the "less than 1d" guard was added in
org-habit.el. So, perhaps it'd make sense to update org-habit.el to
support hour repeaters, particularly if habit users say there's a need.
As a non-habit user reading through (info "(org)Tracking your habits"),
I'm a bit worried that your patch only works superficially. That node
talks about "graphs that show every day" and "colors for each day"; does
that sort of logic break down with your proposed changes?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
2020-07-29 2:29 ` Kyle Meyer
@ 2020-07-29 11:06 ` Gustavo Barros
[not found] ` <87a6zi5qgu.fsf@nivekuil.com>
0 siblings, 1 reply; 8+ messages in thread
From: Gustavo Barros @ 2020-07-29 11:06 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Kevin Liu, emacs-orgmode
Hi Kyle, Hi Kevin,
On Tue, 28 Jul 2020 at 22:29, Kyle Meyer <kyle@kyleam.com> wrote:
> Kevin Liu writes:
>
>>> Is there any way to do this or are the docs out of date?
>>
>> I made a few quick changes to org-habit and it works prima facie. Will
>> continue testing for a bit.
>
> The hourly repeater came in ec921a2a6 (Support hourly repeat cookies,
> 2012-04-20), well after the "less than 1d" guard was added in
> org-habit.el. So, perhaps it'd make sense to update org-habit.el to
> support hour repeaters, particularly if habit users say there's a need.
>
> As a non-habit user reading through (info "(org)Tracking your habits"),
> I'm a bit worried that your patch only works superficially. That node
> talks about "graphs that show every day" and "colors for each day"; does
> that sort of logic break down with your proposed changes?
As far as I know, indeed, org-habit provides essentially a consistency
graph, which shows in the agenda the regularity of the task for a
certain period, being the day the least (and only) unit of the graph (1
day = 1 character).
I don't think the proposed change would break anything (just a cursory
look though) but, unless I'm missing something Kevin has in mind, I
don't see how it would be of use, because an hourly repeater cannot
really be properly conveyed in the consistency graph of org-habit. So,
as far as I understand, there is nothing wrong either in the
documentation or in org-habits. It is just that habits tasks are a
particular kind of repeating task, and tasks that repeat in frequencies
smaller than a day cannot be properly represented in the consistency
graphs, though they work as documented in other cases.
Kevin, how do you see an hourly repeater would work with org-habit's
consistency graph? Or, more generally, what would be the purpose of an
hourly repeated habit task?
Best,
Gustavo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
[not found] ` <87a6zi5qgu.fsf@nivekuil.com>
@ 2020-07-29 15:15 ` Gustavo Barros
2020-07-29 15:41 ` Kevin Liu
0 siblings, 1 reply; 8+ messages in thread
From: Gustavo Barros @ 2020-07-29 15:15 UTC (permalink / raw)
To: Kevin Liu; +Cc: emacs-orgmode
Hi Kevin,
On Wed, 29 Jul 2020 at 11:46, Kevin Liu <kevin@nivekuil.com> wrote:
> On 29 July 2020 04:06, Gustavo Barros <gusbrs.2016@gmail.com> wrote:
>>
>> Kevin, how do you see an hourly repeater would work with org-habit's
>> consistency graph? Or, more generally, what would be the purpose of
>> an
>> hourly repeated habit task?
>
> An example of an hourly repeated habit task is exercise. You might
> want
> to stretch in the morning and then again at night.
>
> You raise a good point that the consistency graph isn't as useful as
> it
> could be. All it shows now is that the habit was done at least once
> on
> that day. I think this is still a little useful, if only to visually
> separate a habit from other tasks on the agenda. It could be made
> more
> useful by replacing the * with a count of the number of times the task
> was done that day, but that would be another patch.
I get why a task (exercising, taking medicine, etc) is usefully repeated
a number of times a day, of course. But a regular repeating task is
perfectly fine for this. Furthermore, considering the only thing
org-habit does is to provide the consistency graph for the task, and if
this does not really work for hourly repeaters, I still don't see the
gain here. And there would be other ways, in my view more appropriate
ones, to separate some tasks, if that's desired. IMHO, what you are
proposing is just eliminating an error message which was deliberately
placed there by the author, considering what org-habit is designed to
do. But this is just an user speaking, take this as a data point.
Anyway, you have replied just for me, off-list. I presume you meant
otherwise, and your point is relevant in the list, so I reincluded the
CCs to it.
Best,
Gustavo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
2020-07-29 15:15 ` Gustavo Barros
@ 2020-07-29 15:41 ` Kevin Liu
2020-07-29 16:29 ` Gustavo Barros
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Liu @ 2020-07-29 15:41 UTC (permalink / raw)
To: Gustavo Barros; +Cc: emacs-orgmode
On 29 July 2020 08:15, Gustavo Barros <gusbrs.2016@gmail.com> wrote:
> Furthermore, considering the only thing org-habit does is to provide
> the consistency graph for the task, and if this does not really work
> for hourly repeaters, I still don't see the gain here. And there
> would be other ways, in my view more appropriate ones, to separate
> some tasks, if that's desired. IMHO, what you are proposing is just
> eliminating an error message which was deliberately placed there by
> the author, considering what org-habit is designed to do. But this is
> just an user speaking, take this as a data point.
The graph works for hourly repeaters in exactly the same way as it works
in all other cases. It illustrates whether the task was done on a given
day.
The gain is being able to use org-habit at all with hourly repeating
tasks. At the moment, this is unnecessarily precluded, and not even by
the error I removed; the actual error that pops up if you build the
agenda with an hourly habit is rather cryptic:
if: Invalid duration string: .+5h
As Kyle mentioned, I don't think authorial intent counts for a whole lot
here since the code was last touched in 2009, years before hourly
repeaters were added.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
2020-07-29 15:41 ` Kevin Liu
@ 2020-07-29 16:29 ` Gustavo Barros
2020-07-30 15:25 ` Kevin Liu
0 siblings, 1 reply; 8+ messages in thread
From: Gustavo Barros @ 2020-07-29 16:29 UTC (permalink / raw)
To: Kevin Liu; +Cc: emacs-orgmode
On Wed, 29 Jul 2020 at 12:41, Kevin Liu <kevin@nivekuil.com> wrote:
> The graph works for hourly repeaters in exactly the same way as it
> works
> in all other cases. It illustrates whether the task was done on a
> given
> day.
But what will happen is that the task will be both "done" and "due" on
the same day. Which face shall org-habit use? Which symbol? The task
will be shown in the agenda, all right, whether the consistency graph is
meaningful is another matter.
> As Kyle mentioned, I don't think authorial intent counts for a whole
> lot
> here since the code was last touched in 2009, years before hourly
> repeaters were added.
I'm not so sure. Take a look at commit be2806d281 "Fixes to the
consistency graph in org-habit", by John Wiegley, in 2009-10-22.
There the following error check was then introduced:
(unless (> sr-days 0)
(error "Habit's scheduled repeat period is less than 1d"))
Considering `sr-days' was then let-bound with:
(scheduled-repeat (org-get-repeat "SCHEDULED"))
(sr-days (org-habit-duration-to-days scheduled-repeat))
And that `org-habit-duration-to-days' performs its conversion of the
repeaters to days with `floor', I'd say it is pretty deliberate. If
this was before the introduction of hourly repeaters, I'd take this to
be even more meaningful, not less.
Best,
Gustavo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Repeating task hourly
2020-07-29 16:29 ` Gustavo Barros
@ 2020-07-30 15:25 ` Kevin Liu
0 siblings, 0 replies; 8+ messages in thread
From: Kevin Liu @ 2020-07-30 15:25 UTC (permalink / raw)
To: Gustavo Barros; +Cc: emacs-orgmode
On 29 July 2020 09:29, Gustavo Barros <gusbrs.2016@gmail.com> wrote:
> But what will happen is that the task will be both "done" and "due" on
> the same day. Which face shall org-habit use? Which symbol?
> And that `org-habit-duration-to-days' performs its conversion of the
> repeaters to days with `floor', I'd say it is pretty deliberate.
Good catch, with sub-day intervals sr-days is always 0 so it's always
overdue. A quick workaround is to change the floor to a ceiling and
maybe flooring the month/year values manually, so it would
only affect 3m+ and 4y+ habits by a day.
> this was before the introduction of hourly repeaters, I'd take this to
> be even more meaningful, not less.
How do you figure?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-07-30 15:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-27 11:30 Repeating task hourly Kevin Liu
2020-07-27 11:40 ` Kevin Liu
2020-07-29 2:29 ` Kyle Meyer
2020-07-29 11:06 ` Gustavo Barros
[not found] ` <87a6zi5qgu.fsf@nivekuil.com>
2020-07-29 15:15 ` Gustavo Barros
2020-07-29 15:41 ` Kevin Liu
2020-07-29 16:29 ` Gustavo Barros
2020-07-30 15:25 ` Kevin Liu
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).