emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thomas Morgan <tlm@ziiuu.com>
To: emacs-orgmode@gnu.org
Subject: Giving priority to overdue habits that repeat more frequently
Date: Sat, 26 Oct 2013 16:06:11 +0200	[thread overview]
Message-ID: <87txg4m8j0.fsf@azha.ziiuu.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Give-priority-to-overdue-habits-that-repeat-more-fre.patch --]
[-- Type: text/x-diff, Size: 2190 bytes --]

From cc25d929f6eafeda89c75364068572d0aed3502d Mon Sep 17 00:00:00 2001
From: Thomas Morgan <tlm@ziiuu.com>
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


                 reply	other threads:[~2013-10-26 15:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87txg4m8j0.fsf@azha.ziiuu.com \
    --to=tlm@ziiuu.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).