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 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
* [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

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