emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days
@ 2019-02-03 15:44 John Lee
  0 siblings, 0 replies; 6+ messages in thread
From: John Lee @ 2019-02-03 15:44 UTC (permalink / raw)
  To: Org Mode List

* lisp/org-habit.el (org-habit-scheduled-past-days): New variable

* lisp/org-agenda.el (org-agenda-get-scheduled): override
  `org-scheduled-past-days' for habits if
  `org-habit-scheduled-past-days` is not nil

TINYCHANGE
---
 lisp/org-agenda.el |  8 +++++++-
 lisp/org-habit.el  | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 489ecec95..9145cafa8 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -90,6 +90,7 @@
 (defvar org-habit-show-habits)
 (defvar org-habit-show-habits-only-for-today)
 (defvar org-habit-show-all-today)
+(defvar org-habit-scheduled-past-days)
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")
@@ -6201,7 +6202,12 @@ 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
+			     (if (null org-habit-scheduled-past-days)
+				 org-scheduled-past-days
+			       org-habit-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 af4520729..88df38ce0 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-scheduled-past-days nil
+"Value to use instead of `org-scheduled-past-days', for habits only.
+
+If nil, `org-scheduled-past-days' is used.
+
+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 '(choice integer (const nil))
+  :package-version '(Org . "9.3")
+  :safe (lambda (v) (or (integerp v) (null v))))
+
 (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

* [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days
@ 2019-02-03 16:03 John Lee
  2019-02-03 16:14 ` John Lee
  0 siblings, 1 reply; 6+ messages in thread
From: John Lee @ 2019-02-03 16:03 UTC (permalink / raw)
  To: emacs-orgmode

* lisp/org-habit.el (org-habit-scheduled-past-days): New variable

* lisp/org-agenda.el (org-agenda-get-scheduled): override
  `org-scheduled-past-days' for habits if
  `org-habit-scheduled-past-days` is not nil

TINYCHANGE
---
 lisp/org-agenda.el |  4 +++-
 lisp/org-habit.el  | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 489ecec95..784a555a9 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -90,6 +90,7 @@
 (defvar org-habit-show-habits)
 (defvar org-habit-show-habits-only-for-today)
 (defvar org-habit-show-all-today)
+(defvar org-habit-scheduled-past-days)
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")
@@ -6201,7 +6202,8 @@ 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 (or (and habitp org-habit-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 af4520729..88df38ce0 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-scheduled-past-days nil
+"Value to use instead of `org-scheduled-past-days', for habits only.
+
+If nil, `org-scheduled-past-days' is used.
+
+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 '(choice integer (const nil))
+  :package-version '(Org . "9.3")
+  :safe (lambda (v) (or (integerp v) (null v))))
+
 (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

* Re: [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days
  2019-02-03 16:03 [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days John Lee
@ 2019-02-03 16:14 ` John Lee
  2019-02-06 21:32   ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: John Lee @ 2019-02-03 16:14 UTC (permalink / raw)
  To: emacs-orgmode

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

OK I guess in fact I'm 1. supposed to attach the patches (?) and 2. they contain hashes so I guess I should reattach them all together, having changed the first.  Here they are.  Sorry, I'm new to this email workflow.

The new thing here since Nicolas reviewed this last year (apart from applying changes in response to review feedback) is "greying out" habits that you just did, by applying face 'org-agenda-done when a habit is scheduled for the future.

On Sun, 3 Feb 2019, at 16:03, John Lee wrote:
> * lisp/org-habit.el (org-habit-scheduled-past-days): New variable
> 
> * lisp/org-agenda.el (org-agenda-get-scheduled): override
>   `org-scheduled-past-days' for habits if
>   `org-habit-scheduled-past-days` is not nil
> 
> TINYCHANGE
> ---
>  lisp/org-agenda.el |  4 +++-
>  lisp/org-habit.el  | 15 +++++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 489ecec95..784a555a9 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -90,6 +90,7 @@
>  (defvar org-habit-show-habits)
>  (defvar org-habit-show-habits-only-for-today)
>  (defvar org-habit-show-all-today)
> +(defvar org-habit-scheduled-past-days)
>  
>  ;; Defined somewhere in this file, but used before definition.
>  (defvar org-agenda-buffer-name "*Org Agenda*")
> @@ -6201,7 +6202,8 @@ 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 (or (and habitp org-habit-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 af4520729..88df38ce0 100644
> --- a/lisp/org-habit.el
> +++ b/lisp/org-habit.el
> @@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
>    :group 'org-habit
>    :type 'boolean)
>  
> +(defcustom org-habit-scheduled-past-days nil
> +"Value to use instead of `org-scheduled-past-days', for habits only.
> +
> +If nil, `org-scheduled-past-days' is used.
> +
> +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 '(choice integer (const nil))
> +  :package-version '(Org . "9.3")
> +  :safe (lambda (v) (or (integerp v) (null v))))
> +
>  (defface org-habit-clear-face
>    '((((background light)) (:background "#8270f9"))
>      (((background dark)) (:background "blue")))
> -- 
> 2.17.1
> 
> 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-habit-Add-org-habit-scheduled-past-days.patch --]
[-- Type: text/x-patch; name="0001-org-habit-Add-org-habit-scheduled-past-days.patch", Size: 2419 bytes --]

From 81a56b4b2fd8bfa92695a8386158f6e03584f948 Mon Sep 17 00:00:00 2001
From: John Lee <jjl@pobox.com>
Date: Sun, 3 Feb 2019 12:35:39 +0000
Subject: [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days

* lisp/org-habit.el (org-habit-scheduled-past-days): New variable

* lisp/org-agenda.el (org-agenda-get-scheduled): override
  `org-scheduled-past-days' for habits if
  `org-habit-scheduled-past-days` is not nil

TINYCHANGE
---
 lisp/org-agenda.el |  4 +++-
 lisp/org-habit.el  | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 489ecec95..784a555a9 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -90,6 +90,7 @@
 (defvar org-habit-show-habits)
 (defvar org-habit-show-habits-only-for-today)
 (defvar org-habit-show-all-today)
+(defvar org-habit-scheduled-past-days)
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")
@@ -6201,7 +6202,8 @@ 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 (or (and habitp org-habit-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 af4520729..88df38ce0 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-scheduled-past-days nil
+"Value to use instead of `org-scheduled-past-days', for habits only.
+
+If nil, `org-scheduled-past-days' is used.
+
+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 '(choice integer (const nil))
+  :package-version '(Org . "9.3")
+  :safe (lambda (v) (or (integerp v) (null v))))
+
 (defface org-habit-clear-face
   '((((background light)) (:background "#8270f9"))
     (((background dark)) (:background "blue")))
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-org-habit-Always-show-time-of-day-designation-for-ha.patch --]
[-- Type: text/x-patch; name="0002-org-habit-Always-show-time-of-day-designation-for-ha.patch", Size: 1454 bytes --]

From 5a0ca7b27985aafd10447aa24089b7f5782e4c9c Mon Sep 17 00:00:00 2001
From: John Lee <jjl@pobox.com>
Date: Sun, 3 Feb 2019 12:36:03 +0000
Subject: [PATCH 2/3] org-habit: Always show time of day designation for habits

* org-agenda.el (org-agenda-get-scheduled): Always show the time of
  day designation for habits

TINYCHANGE
---
 lisp/org-agenda.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 784a555a9..203c1e9d4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6257,9 +6257,17 @@ 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, except for habits, which always show
+		     ;; the time of day.  Habits are an exception
+		     ;; because if there is a time of day, that is
+		     ;; interpreted to mean they should usually happen
+		     ;; then, even if doing the habit was missed.
+		     ((and
+		       (not habitp)
+		       (/= current schedule)
+		       (/= current repeat))
+		      nil)
 		     ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
 		      (concat (substring s (match-beginning 1)) " "))
 		     (t 'time)))
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-org-habit-Use-face-org-agenda-done-for-habits-schedu.patch --]
[-- Type: text/x-patch; name="0003-org-habit-Use-face-org-agenda-done-for-habits-schedu.patch", Size: 1435 bytes --]

From c2d4b66876f025e9b2cf46f9e95e58d7f2b5373a Mon Sep 17 00:00:00 2001
From: John Lee <jjl@pobox.com>
Date: Mon, 26 Nov 2018 13:08:20 +0000
Subject: [PATCH 3/3] org-habit: Use face 'org-agenda-done for habits scheduled
 for future

* lisp/org-agenda.el (org-agenda-get-scheduled): Use the face.

This has the effect that if you just did the habit, it is "greyed out"
in the agenda.

TINYCHANGE
---
 lisp/org-agenda.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 203c1e9d4..2765718ac 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6165,6 +6165,7 @@ scheduled items with an hour specification like [h]h:mm."
 	       (diff (- current schedule))
 	       (warntime (get-text-property (point) 'org-appt-warntime))
 	       (pastschedp (< schedule today))
+	       (futureschedp (> schedule today))
 	       (habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p)))
 	       (suppress-delay
 		(let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
@@ -6281,6 +6282,8 @@ scheduled items with an hour specification like [h]h:mm."
 		     head level category tags time nil habitp))
 		   (face (cond ((and (not habitp) pastschedp)
 				'org-scheduled-previously)
+			       ((and habitp futureschedp)
+				'org-agenda-done)
 			       (todayp 'org-scheduled-today)
 			       (t 'org-scheduled)))
 		   (habitp (and habitp (org-habit-parse-todo))))
-- 
2.17.1


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

* Re: [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days
  2019-02-03 16:14 ` John Lee
@ 2019-02-06 21:32   ` Nicolas Goaziou
  2019-02-07 21:27     ` John Lee
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2019-02-06 21:32 UTC (permalink / raw)
  To: John Lee; +Cc: emacs-orgmode

Hello,

John Lee <jjl@pobox.com> writes:

> OK I guess in fact I'm 1. supposed to attach the patches (?) 

You can also thread them.

> The new thing here since Nicolas reviewed this last year (apart from
> applying changes in response to review feedback) is "greying out"
> habits that you just did, by applying face 'org-agenda-done when
> a habit is scheduled for the future.

I applied them in master. Thank you.

Could you provide an entry for ORG-NEWS file, too?

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days
  2019-02-06 21:32   ` Nicolas Goaziou
@ 2019-02-07 21:27     ` John Lee
  2019-02-08 23:17       ` John Lee
  0 siblings, 1 reply; 6+ messages in thread
From: John Lee @ 2019-02-07 21:27 UTC (permalink / raw)
  To: emacs-orgmode

On Wed, 6 Feb 2019, at 21:32, Nicolas Goaziou wrote:
> I applied them in master. Thank you.

Thank you!

> Could you provide an entry for ORG-NEWS file, too?

Will do.

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

* Re: [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days
  2019-02-07 21:27     ` John Lee
@ 2019-02-08 23:17       ` John Lee
  0 siblings, 0 replies; 6+ messages in thread
From: John Lee @ 2019-02-08 23:17 UTC (permalink / raw)
  To: emacs-orgmode

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

On Thu, 7 Feb 2019, at 21:27, John Lee wrote:
> On Wed, 6 Feb 2019, at 21:32, Nicolas Goaziou wrote:
> > I applied them in master. Thank you.
> 
> Thank you!
> 
> > Could you provide an entry for ORG-NEWS file, too?

Attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-to-ORG-NEWS-for-recent-org-habit-changes.patch --]
[-- Type: text/x-patch; name="0001-Add-to-ORG-NEWS-for-recent-org-habit-changes.patch", Size: 2489 bytes --]

From ded5296358ec2bcfbe58a662b5112226298bf43f Mon Sep 17 00:00:00 2001
From: John Lee <jjl@pobox.com>
Date: Fri, 8 Feb 2019 23:13:01 +0000
Subject: [PATCH] Add to ORG-NEWS for recent org-habit changes

---
 etc/ORG-NEWS | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index bf14412fd..595d1895c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,16 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 * Version 9.3
 
 ** Incompatible changes
+*** org-agenda now always shows the time of day for ~org-habit~ habits
+
+Scheduled items with an associated time of day don't normally show the
+time in the agenda if they were missed, because they're regarded as
+only a reminder of a specific appointment that was already missed.
+That behaviour is unchanged, except for scheduled items that represent
+~org-habit~ habits, which now always show any time designation,
+because the time of a habit is regarded as the time when the habit
+should be done, even if one repeat was missed.
+
 *** ob-clojure will not auto prepend ~(ns ..)~ statement now
 When tangling, user usually just want to tangle literally code instead
 of prepend inserting a ~(ns ..)~ statement before source block
@@ -54,6 +64,16 @@ alternative was removed and there is no more a :use-xcolor options
 since now it's implicitly always true.
 
 ** New features
+*** Support showing missed habits when ~org-scheduled-past-days~ is in effect
+
+This supports GTD-style workflows in which scheduled items are used as
+a way of "turning on" TODO items on a particular date, rather than as
+a means of creating calendar-based reminders to do tasks.  It was
+possible to achieve that using ~org-scheduled-past-days~, but that
+caused some habits to not be shown when it was time to do the habit.
+~org-habit-scheduled-past-days~ overrides that variable just for
+~org-habit~ items.
+
 *** Handle overlay specification for notes in Beamer export
 
 This aligns Beamer notes with slide overlays.
@@ -136,6 +156,11 @@ dynamic block in ~org-dynamic-block-alist~.
 It was unused throughout the code base.
 
 ** Miscellaneous
+*** Use face ~org-agenda-done~ for habits scheduled for future
+
+This has the effect that if you just did the habit, it is "greyed out"
+in the agenda (given appropriate face configuration).
+
 *** No more special indentation for description items
 
 Descriptions items are indented like regular ones, i.e., text starts
-- 
2.17.1


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

end of thread, other threads:[~2019-02-08 23:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-03 16:03 [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days John Lee
2019-02-03 16:14 ` John Lee
2019-02-06 21:32   ` Nicolas Goaziou
2019-02-07 21:27     ` John Lee
2019-02-08 23:17       ` John Lee
  -- strict thread matches above, loose matches on Subject: below --
2019-02-03 15:44 John Lee

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).