From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Lee Subject: org-habit: allow overriding org-scheduled-past-days and always including time of day Date: Mon, 05 Nov 2018 00:31:00 +0000 Message-ID: <1541377860.1107531.1565461832.5F447B5E@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJSty-0000aC-9t for emacs-orgmode@gnu.org; Sun, 04 Nov 2018 19:38:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJSnH-0007yj-T5 for emacs-orgmode@gnu.org; Sun, 04 Nov 2018 19:31:07 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:55803) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gJSnH-0007xs-C7 for emacs-orgmode@gnu.org; Sun, 04 Nov 2018 19:31:03 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id A413B21BBA for ; Sun, 4 Nov 2018 19:31:00 -0500 (EST) 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" To: emacs-orgmode@gnu.org Hi Here's a couple of patches that add new org-habit variables. I hope the variable documentation describes them sufficiently: if not I need to change the docs so if you review these patches please read the patch before the rest of this email so that you're not "cheating"! Does the idea behind each of these seem appropriate to people? They work for me of course, and behaviour is unchanged unless you set non-default values for the new variables -- but I know people have different workflows. My own workflow around this is similar to GTD, so I'm using SCHEDULED as basically a way to get TODO items to show up after the scheduled date, not to show up in the calendar except as a reminder that I have new TODOs. For that reason I set org-scheduled-past-days to a low value (3 right now). I also set org-agenda-todo-ignore-scheduled to 'future and org-agenda-tags-todo-honor-ignore-options to t (not directly relevant here except as context). For habits that causes habits not to show up sometimes because of the short org-scheduled-past-days, which isn't appropriate for my habits: if I say .+5d, I still want to see the habit there if it's due, even if it's been 4 days since the last done date (which is more than the 3 days of org-scheduled-past-days). This motivates `org-habit-schedul ed-past-days'. Similarly, since I want to do some of my habits at a particular time of day, org-agenda's omitting of the time of day from the scheduled timestamp if this is a "repeat" (i.e. I missed doing the habit) is unhelpful for habits, because now I have to scan though a long-ish list of habits (5 or 10 right now!) and think "is now the right time, should I have done that already?" for every habit in the list, rather than just eyeballing it to see which ones are around now in time. This motivates `org-habit-always-show-time'. I have not yet submitted the FSF copyright assignment form but am prepared to do so. >From 7bcf7b70b201af7a3d3cbbcf6a95511944370627 Mon Sep 17 00:00:00 2001 From: John Lee Date: Sun, 4 Nov 2018 23:11:17 +0000 Subject: [PATCH 1/2] org-habit: Add org-habit-scheduled-past-days * lisp/org-habit.el: Add new variable `org-habit-scheduled-past-days' to allow overriding `org-scheduled-past-days' for habits * lisp/org-agenda.el (org-agenda-get-scheduled): override `org-scheduled-past-days' for habits if `org-habit-scheduled-past-days` is not nil --- lisp/org-agenda.el | 5 ++++- lisp/org-habit.el | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 180a0612c..e2bd5cc2d 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6196,7 +6196,10 @@ scheduled items with an hour specification like [h]h:mm." habitp (bound-and-true-p org-habit-show-all-today)) (when (or (and (> ddays 0) (< diff ddays)) - (> diff org-scheduled-past-days) + (> diff (if habitp + (or org-habit-scheduled-past-days + org-scheduled-past-days) + org-scheduled-past-days)) (> schedule current) (and (/= current schedule) (/= current today) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index 375714e35..b8415bdde 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -89,6 +89,17 @@ It will be green even if it was done after the deadline." :group 'org-habit :type 'boolean) +(defcustom org-habit-scheduled-past-days nil + "Non-nil means the value of this variable will be used instead +of org-scheduled-past-days, for habits only. +Setting this to say 10000 is a way to make habits always show up +as a reminder, even if you set org-scheduled-past-days to a small +value because you regard SCHEDULED items as a way of 'turning on' +TODO items on a particular date, rather than as a means of +creating calendar-based reminders." + :group 'org-habit + :type 'integer) + (defface org-habit-clear-face '((((background light)) (:background "#8270f9")) (((background dark)) (:background "blue"))) -- 2.17.1 >From a1d6e3af978237b3f555682a111c2439f17b45b9 Mon Sep 17 00:00:00 2001 From: John Lee Date: Sun, 4 Nov 2018 23:17:15 +0000 Subject: [PATCH 2/2] org-habit: Add org-habit-always-show-time * lisp/org-habit.el: Add new variable `org-habit-always-show-time' to force always showing the time of day * lisp/org-agenda.el (org-agenda-get-scheduled): honour `org-habit-always-show-time` --- lisp/org-agenda.el | 12 +++++++++--- lisp/org-habit.el | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index e2bd5cc2d..08e286730 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6253,9 +6253,15 @@ scheduled items with an hour specification like [h]h:mm." (head (buffer-substring (point) (line-end-position))) (time (cond - ;; No time of day designation if it is only - ;; a reminder. - ((and (/= current schedule) (/= current repeat)) nil) + ;; No time of day designation if it is only a + ;; reminder (unless org-habit-always-show-time + ;; forces display of the time of day + ;; designation). + ((and + (not (and habitp org-habit-always-show-time)) + (/= current schedule) + (/= current repeat)) + nil) ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) (concat (substring s (match-beginning 1)) " ")) (t 'time))) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index b8415bdde..7215174f9 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -100,6 +100,16 @@ creating calendar-based reminders." :group 'org-habit :type 'integer) +(defcustom org-habit-always-show-time nil + "Non-nil means always show the time of day designation from the +timestamp, even if the habit is past its due date. +Setting this to t is useful if you regard the time of day +designation in some of your habits' scheduled timestamps as a +guide to when to do the habit, rather than only a time after +which the habit is due." + :group 'org-habit + :type 'boolean) + (defface org-habit-clear-face '((((background light)) (:background "#8270f9")) (((background dark)) (:background "blue"))) -- 2.17.1