浏览代码

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.
Nicolas Goaziou 8 年之前
父节点
当前提交
d73942cf99
共有 2 个文件被更改,包括 26 次插入12 次删除
  1. 2 0
      etc/ORG-NEWS
  2. 24 12
      lisp/org-agenda.el

+ 2 - 0
etc/ORG-NEWS

@@ -86,6 +86,8 @@ docstrings.
 *** Agenda
 *** Agenda
 **** New variable : ~org-agenda-show-future-repeats~
 **** New variable : ~org-agenda-show-future-repeats~
 **** New variable : ~org-agenda-prefer-last-repeat~
 **** 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~
 **** Binding C-c C-x < for ~org-agenda-set-restriction-lock-from-agenda~
 *** New value for ~org-publish-sitemap-sort-folders~
 *** New value for ~org-publish-sitemap-sort-folders~
 
 

+ 24 - 12
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
 this day and will be listed until it is marked done or for the
 number of days given here."
 number of days given here."
   :group 'org-agenda-daily/weekly
   :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)
 (defcustom org-agenda-log-mode-items '(closed clock)
   "List of items that should be shown in agenda log mode.
   "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))
 			  (let ((org-deadline-warning-days suppress-prewarning))
 			    (org-get-wdays s))
 			    (org-get-wdays s))
 			(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.
 	  ;; Possibly skip done tasks.
 	  (when (and done?
 	  (when (and done?
 		     (or org-agenda-skip-deadline-if-done
 		     (or org-agenda-skip-deadline-if-done