--- org-agenda-latest.el 2012-10-17 08:39:50.101427177 +0200 +++ org-agenda-latest-presched.el 2012-10-17 09:17:40.170574930 +0200 @@ -827,9 +827,10 @@ This will apply on all days where a prewarning for the deadline would be shown, but not at the day when the entry is actually due. On that day, the deadline will be shown anyway. -This variable may be set to nil, t, or a number which will then give -the number of days before the actual deadline when the prewarnings -should resume. +This variable may be set to nil, t, the symbol `pre-scheduled', +or a number which will then give the number of days before the actual +deadline when the prewarnings should resume. The symbol `pre-scheduled' +eliminates the deadline prewarning only prior to the scheduled date. This can be used in a workflow where the first showing of the deadline will trigger you to schedule it, and then you don't want to be reminded of it because you will take care of it on the day when scheduled." @@ -838,6 +839,7 @@ :version "24.1" :type '(choice (const :tag "Alwas show prewarning" nil) + (const :tag "Remove prewarning prior to scheduled date" pre-scheduled) (const :tag "Remove prewarning if entry is scheduled" t) (integer :tag "Restart prewarning N days before deadline"))) @@ -5807,23 +5809,13 @@ (regexp org-deadline-time-regexp) (todayp (org-agenda-todayp date)) ; DATE bound by calendar (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar - d2 diff dfrac wdays pos pos1 category category-pos level + ds d2 diff dfrac wdays pos pos1 category category-pos level tags suppress-prewarning ee txt head face s todo-state show-all upcomingp donep timestr warntime) (goto-char (point-min)) (while (re-search-forward regexp nil t) - (setq suppress-prewarning nil) (catch :skip (org-agenda-skip) - (when (and org-agenda-skip-deadline-prewarning-if-scheduled - (save-match-data - (string-match org-scheduled-time-regexp - (buffer-substring (point-at-bol) - (point-at-eol))))) - (setq suppress-prewarning - (if (integerp org-agenda-skip-deadline-prewarning-if-scheduled) - org-agenda-skip-deadline-prewarning-if-scheduled - 0))) (setq s (match-string 1) txt nil pos (1- (match-beginning 1)) @@ -5834,8 +5826,31 @@ d2 (org-time-string-to-absolute (match-string 1) d1 'past show-all (current-buffer) pos) - diff (- d2 d1) - wdays (if suppress-prewarning + diff (- d2 d1)) + (setq suppress-prewarning + (if (and org-agenda-skip-deadline-prewarning-if-scheduled + (let ((item (buffer-substring (point-at-bol) + (point-at-eol)))) + (setq ds (save-match-data + (if (string-match + org-scheduled-time-regexp item) + (match-string 1 item)))))) + ;; If prewarnings of scheduled items are to be skipped + ;; and the current item has a scheduled date (in ds), + ;; calculate prewarning lead time: + (if (integerp + org-agenda-skip-deadline-prewarning-if-scheduled) + ;; use prewarning-restart lead time: + org-agenda-skip-deadline-prewarning-if-scheduled + (if (eq org-agenda-skip-deadline-prewarning-if-scheduled + 'pre-scheduled) + ;; show first prewarning no earlier than scheduled date: + (min (- d2 (org-time-string-to-absolute + ds d1 'past show-all (current-buffer) pos)) + org-deadline-warning-days) + ;; set prewarning to deadline: + 0)))) + (setq wdays (if suppress-prewarning (let ((org-deadline-warning-days suppress-prewarning)) (org-get-wdays s)) (org-get-wdays s))