From d73942cf99c8bf610e56b777615f2c5e09cb0b0b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 7 Mar 2017 01:06:33 +0100 Subject: [PATCH] org-agenda: Implement `org-deadline-past-days' * lisp/org-agenda.el (org-deadline-past-days): New variable. (org-scheduled-past-days): Set :safe keyword. (org-agenda-get-deadlines): Use new variable. --- etc/ORG-NEWS | 2 ++ lisp/org-agenda.el | 36 ++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 29593b460..aa0c7dcd6 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -86,6 +86,8 @@ docstrings. *** Agenda **** New variable : ~org-agenda-show-future-repeats~ **** New variable : ~org-agenda-prefer-last-repeat~ +**** New variable : ~org-deadline-past-days~ +See docstring for details. **** Binding C-c C-x < for ~org-agenda-set-restriction-lock-from-agenda~ *** New value for ~org-publish-sitemap-sort-folders~ diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index c98c32822..0a47836cd 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1292,7 +1292,19 @@ When an item is scheduled on a date, it shows up in the agenda on this day and will be listed until it is marked done or for the number of days given here." :group 'org-agenda-daily/weekly - :type 'integer) + :type 'integer + :safe 'integerp) + +(defcustom org-deadline-past-days 10000 + "Number of days to warn about missed deadlines. +When an item has deadline on a date, it shows up in the agenda on +this day and will appear as a reminder until it is marked DONE or +for the number of days given here." + :group 'org-agenda-daily/weekly + :type 'integer + :version "26.1" + :package-version '(Org . "9.1") + :safe 'integerp) (defcustom org-agenda-log-mode-items '(closed clock) "List of items that should be shown in agenda log mode. @@ -5954,17 +5966,17 @@ specification like [h]h:mm." (let ((org-deadline-warning-days suppress-prewarning)) (org-get-wdays s)) (org-get-wdays s)))) - ;; Display deadlines items at base date (DEADLINE), today, - ;; if deadline is overdue or if the expiration of the - ;; upcoming deadline is within WDAYS warning time. Also, - ;; show any repeat past today. - (when (or (and (/= current deadline) - (/= current today) - (/= current repeat)) - (and today? - (> deadline current) - (> diff wdays))) - (throw :skip nil)) + (cond + ;; Only display deadlines at their base date, at future + ;; repeat occurrences or in today agenda. + ((= current deadline) nil) + ((= current repeat) nil) + ((not today?) (throw :skip nil)) + ;; Upcoming deadline: display within warning period WDAYS. + ((> deadline current) (when (> diff wdays) (throw :skip nil))) + ;; Overdue deadline: warn about it for + ;; `org-deadline-past-days' duration. + (t (when (< org-deadline-past-days (- diff)) (throw :skip nil)))) ;; Possibly skip done tasks. (when (and done? (or org-agenda-skip-deadline-if-done