From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Morgan Subject: Giving priority to overdue habits that repeat more frequently Date: Sat, 26 Oct 2013 16:06:11 +0200 Message-ID: <87txg4m8j0.fsf@azha.ziiuu.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Va5qb-0003ue-G6 for emacs-orgmode@gnu.org; Sat, 26 Oct 2013 11:32:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Va5qV-0000Mb-GN for emacs-orgmode@gnu.org; Sat, 26 Oct 2013 11:32:17 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:43253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Va5qV-0000MP-9h for emacs-orgmode@gnu.org; Sat, 26 Oct 2013 11:32:11 -0400 Received: by mail-lb0-f180.google.com with SMTP id y6so1644262lbh.11 for ; Sat, 26 Oct 2013 08:32:09 -0700 (PDT) Received: from azha.ziiuu.com (93-161-86-42-static.dk.customer.tdc.net. [93.161.86.42]) by mx.google.com with ESMTPSA id b1sm11907646lah.6.2013.10.26.08.32.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Oct 2013 08:32:06 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Dear Org mode hackers, Here is a patch to give priority to overdue habits that repeat more frequently. The number of times a habit would have been done if it had always been on time is made a factor in its urgency score. I'm not sure if this is true for everyone but my more frequently repeating habits are generally the ones I give priority to, so this behavior seems to fit. Thanks, Thomas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Give-priority-to-overdue-habits-that-repeat-more-fre.patch >From cc25d929f6eafeda89c75364068572d0aed3502d Mon Sep 17 00:00:00 2001 From: Thomas Morgan Date: Sun, 28 Jul 2013 17:43:19 +0200 Subject: [PATCH] Give priority to overdue habits that repeat more frequently. lisp/org-habit.el (org-habit-get-priority): Take into account the frequency of overdue habits. Weight those that repeat often higher than those that repeat infrequently. --- lisp/org-habit.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index eba9037..23713cf 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -230,20 +230,30 @@ This must take into account not just urgency, but consistency as well." (let ((pri 1000) (now (if moment (time-to-days moment) (org-today))) (scheduled (org-habit-scheduled habit)) - (deadline (org-habit-deadline habit))) + (deadline (org-habit-deadline habit)) + (s-repeat (org-habit-scheduled-repeat habit)) + (d-repeat (org-habit-deadline-repeat habit))) ;; add 10 for every day past the scheduled date, and subtract for every ;; day before it (setq pri (+ pri (* (- now scheduled) 10))) + ;; if overdue, add 20 for every time it would have been done if + ;; consistently performed on scheduled date + (when (< scheduled now) + (setq pri (+ pri (* (/ (- now scheduled) s-repeat) 20)))) ;; add 50 if the deadline is today (if (and (/= scheduled deadline) (= now deadline)) (setq pri (+ pri 50))) - ;; add 100 for every day beyond the deadline date, and subtract 10 for - ;; every day before it (let ((slip (- now (1- deadline)))) + ;; add 100 for every day beyond the deadline date, and subtract 10 for + ;; every day before it (if (> slip 0) (setq pri (+ pri (* slip 100))) - (setq pri (+ pri (* slip 10))))) + (setq pri (+ pri (* slip 10)))) + ;; if overdue, add 200 for every time it would have been done if + ;; consistently performed the day before deadline + (when (> slip 0) + (setq pri (+ pri (* (/ slip d-repeat) 200))))) pri)) (defun org-habit-get-faces (habit &optional now-days scheduled-days donep) -- 1.7.10.4 --=-=-=--