* org-habit and hourly repeats
@ 2023-01-18 6:38 Felipe Balbi
2023-01-19 10:48 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2023-01-18 6:38 UTC (permalink / raw)
To: emacs-orgmode
Hi,
I'm trying to start using `org-habit' but I noticed that hourly repeats
are not properly parsed by `org-habit-duration-to-days', however that's
a valid use case --- e.g. drinking water, medicine schedule,
physiotherapy sessions during the day, periodically practicing a new
language. For example, here's an easy TODO item that reproduces the
problem:
8< -------------------- cut here --------------------
* TODO Foo
SCHEDULED: <2023-01-18 Wed 11:00 .+8h>
:PROPERTIES:
:STYLE: habit
:END:
8< -------------------- cut here --------------------
It appears that a simple solution would be modify
`org-habit-duration-to-days' to accept the `h' suffix and set it to a
fraction of a day, something like:
8< -------------------- cut here --------------------
(defun org-habit-duration-to-days (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)
'(("h" . 0.042) ("d" . 1)
("w" . 7) ("m" . 30.4)
("y" . 365.25))))))
(error "Invalid duration string: %s" ts)))
8< -------------------- cut here --------------------
Would something like this be an acceptable solution?
--
balbi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-habit and hourly repeats
2023-01-18 6:38 org-habit and hourly repeats Felipe Balbi
@ 2023-01-19 10:48 ` Ihor Radchenko
2023-01-19 10:58 ` Felipe Balbi
0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-01-19 10:48 UTC (permalink / raw)
To: Felipe Balbi; +Cc: emacs-orgmode
Felipe Balbi <balbi@kernel.org> writes:
> I'm trying to start using `org-habit' but I noticed that hourly repeats
> are not properly parsed by `org-habit-duration-to-days', however that's
> a valid use case --- e.g. drinking water, medicine schedule,
> physiotherapy sessions during the day, periodically practicing a new
> language. For example, here's an easy TODO item that reproduces the
> problem:
Habits occurring multiple times a day are not properly supported in
general. See https://list.orgmode.org/orgmode/87leplsggg.fsf@localhost/
> It appears that a simple solution would be modify
> `org-habit-duration-to-days' to accept the `h' suffix and set it to a
> fraction of a day, something like:
>
> 8< -------------------- cut here --------------------
>
> (defun org-habit-duration-to-days (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)
> '(("h" . 0.042) ("d" . 1)
> ("w" . 7) ("m" . 30.4)
> ("y" . 365.25))))))
> (error "Invalid duration string: %s" ts)))
>
> 8< -------------------- cut here --------------------
>
> Would something like this be an acceptable solution?
I afraid that things are not that simple.
--
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-habit and hourly repeats
2023-01-19 10:48 ` Ihor Radchenko
@ 2023-01-19 10:58 ` Felipe Balbi
2023-01-19 11:04 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2023-01-19 10:58 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
Hi,
On Thu, Jan 19, 2023 at 12:47 PM Ihor Radchenko <yantar92@posteo.net> wrote:
>
> Felipe Balbi <balbi@kernel.org> writes:
>
> > I'm trying to start using `org-habit' but I noticed that hourly repeats
> > are not properly parsed by `org-habit-duration-to-days', however that's
> > a valid use case --- e.g. drinking water, medicine schedule,
> > physiotherapy sessions during the day, periodically practicing a new
> > language. For example, here's an easy TODO item that reproduces the
> > problem:
>
> Habits occurring multiple times a day are not properly supported in
> general. See https://list.orgmode.org/orgmode/87leplsggg.fsf@localhost/
That's very interesting, because repeated tasks clearly mention hourly repeats:
https://orgmode.org/manual/Repeated-tasks.html
"You can use yearly, monthly, weekly, daily and hourly repeat cookies by
using the ‘y’, ‘m’, ‘w’, ‘d’ and ‘h’ letters."
>
> > It appears that a simple solution would be modify
> > `org-habit-duration-to-days' to accept the `h' suffix and set it to a
> > fraction of a day, something like:
> >
> > 8< -------------------- cut here --------------------
> >
> > (defun org-habit-duration-to-days (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)
> > '(("h" . 0.042) ("d" . 1)
> > ("w" . 7) ("m" . 30.4)
> > ("y" . 365.25))))))
> > (error "Invalid duration string: %s" ts)))
> >
> > 8< -------------------- cut here --------------------
> >
> > Would something like this be an acceptable solution?
>
> I afraid that things are not that simple.
Do you mind expanding on this? Just generally curious, really.
--
balbi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-habit and hourly repeats
2023-01-19 10:58 ` Felipe Balbi
@ 2023-01-19 11:04 ` Ihor Radchenko
2023-01-19 11:06 ` Felipe Balbi
0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-01-19 11:04 UTC (permalink / raw)
To: Felipe Balbi; +Cc: emacs-orgmode
Felipe Balbi <balbi@kernel.org> writes:
>> Habits occurring multiple times a day are not properly supported in
>> general. See https://list.orgmode.org/orgmode/87leplsggg.fsf@localhost/
>
> That's very interesting, because repeated tasks clearly mention hourly repeats:
>
> https://orgmode.org/manual/Repeated-tasks.html
>
> "You can use yearly, monthly, weekly, daily and hourly repeat cookies by
> using the ‘y’, ‘m’, ‘w’, ‘d’ and ‘h’ letters."
Repeated tasks do support hourly repeats. But not habits, as long as
habit-specific logic is concerned.
>> I afraid that things are not that simple.
>
> Do you mind expanding on this? Just generally curious, really.
I tried to list some things in
https://list.orgmode.org/orgmode/87leplsggg.fsf@localhost/
For example, habit consistency graph assumes that habits are repeated
every day or longer.
Generally, adding hourly habits will require careful checking of
org-habit.el code. In addition, org-agenda cannot display repeated tasks
when their repeat interval is less than a day (it is a minor annoyance
though; should not be a blocker)
--
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-habit and hourly repeats
2023-01-19 11:04 ` Ihor Radchenko
@ 2023-01-19 11:06 ` Felipe Balbi
2023-01-19 11:13 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2023-01-19 11:06 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
Hi,
On Thu, Jan 19, 2023 at 1:03 PM Ihor Radchenko <yantar92@posteo.net> wrote:
> > That's very interesting, because repeated tasks clearly mention hourly repeats:
> >
> > https://orgmode.org/manual/Repeated-tasks.html
> >
> > "You can use yearly, monthly, weekly, daily and hourly repeat cookies by
> > using the ‘y’, ‘m’, ‘w’, ‘d’ and ‘h’ letters."
>
> Repeated tasks do support hourly repeats. But not habits, as long as
> habit-specific logic is concerned.
Got it :-)
> >> I afraid that things are not that simple.
> >
> > Do you mind expanding on this? Just generally curious, really.
>
> I tried to list some things in
> https://list.orgmode.org/orgmode/87leplsggg.fsf@localhost/
>
> For example, habit consistency graph assumes that habits are repeated
> every day or longer.
>
> Generally, adding hourly habits will require careful checking of
> org-habit.el code. In addition, org-agenda cannot display repeated tasks
> when their repeat interval is less than a day (it is a minor annoyance
> though; should not be a blocker)
Thanks for the links and information. It's unfortunate that it's not supported,
but I guess I can live with it, no problem :-)
cheers
--
balbi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-19 11:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-18 6:38 org-habit and hourly repeats Felipe Balbi
2023-01-19 10:48 ` Ihor Radchenko
2023-01-19 10:58 ` Felipe Balbi
2023-01-19 11:04 ` Ihor Radchenko
2023-01-19 11:06 ` Felipe Balbi
2023-01-19 11:13 ` Ihor Radchenko
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).