emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kevin Liu <kevin@nivekuil.com>
To: emacs-orgmode@gnu.org
Subject: Re: Repeating task hourly
Date: Mon, 27 Jul 2020 04:40:19 -0700	[thread overview]
Message-ID: <87lfj5gp98.fsf@nivekuil.com> (raw)
In-Reply-To: <87o8o1gpow.fsf@nivekuil.com>

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


  reply	other threads:[~2020-07-27 11:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 11:30 Repeating task hourly Kevin Liu
2020-07-27 11:40 ` Kevin Liu [this message]
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

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=87lfj5gp98.fsf@nivekuil.com \
    --to=kevin@nivekuil.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).