From e690d7b43143410d5d5af524bb1ff0819feebc24 Mon Sep 17 00:00:00 2001 From: nivekuil 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