all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-habit: allow overriding org-scheduled-past-days and always including time of day
@ 2018-11-05  0:31 John Lee
  2018-11-05 13:01 ` [PATCH] " John Lee
  2018-11-18 23:40 ` Nicolas Goaziou
  0 siblings, 2 replies; 6+ messages in thread
From: John Lee @ 2018-11-05  0:31 UTC (permalink / raw)
  To: emacs-orgmode

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 <jjl@pobox.com>
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 <jjl@pobox.com>
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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-03 15:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-05  0:31 org-habit: allow overriding org-scheduled-past-days and always including time of day John Lee
2018-11-05 13:01 ` [PATCH] " John Lee
2018-11-18 23:40 ` Nicolas Goaziou
2019-02-02 18:50   ` John Lee
2019-02-02 21:45     ` Nicolas Goaziou
2019-02-03 15:53   ` John Lee

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.