Ihor Radchenko <yanta...@posteo.net> writes: > Morgan Smith <morgan.j.sm...@outlook.com> writes: > >> lisp/org-agenda.el (org-agenda-get-scheduled): Consolidate deadline >> fetching code. Don't check if deadline is shown when >> 'org-agenda-skip-scheduled-if-deadline-is-shown' has a value of >> 'repeated-after-deadline'. >> >> Currently when 'org-agenda-skip-scheduled-if-deadline-is-shown' has a >> value of 'repeated-after-deadline' then there is no effect. This is >> because when 'org-agenda-get-scheduled' is run on later dates, the >> previous deadlines are not put in 'deadline-pos'. > > May you please provide a detailed reproducer demonstrating the bug you > are trying to fix? Such reproducer could be a basis of a new test.
See a detailed reproducer attached to this mail. It has a task defined as this: * TODO task SCHEDULED: <2017-03-06 Mon +2d> DEADLINE: <2017-03-10> Running said reproducer currently fails as follows (the numbers are the days of the month). (string-equal "06\nScheduled: task\n08\nScheduled: task\n10\nScheduled: task\nDeadline: task\n" "06\nScheduled: task\n08\nScheduled: task\n10\nScheduled: task\nDeadline: task\n12\nScheduled: task\n") As you can see, we expect to not see anything scheduled after the deadline if 'org-agenda-skip-scheduled-if-deadline-is-shown' is set to 'repeated-after-deadline', however, we actually see that things continue to be scheduled. Hence the bug is that that option currently does nothing.
>From d7e72b9f0189b98d7ae59f0a56d54ffe70583956 Mon Sep 17 00:00:00 2001 From: Morgan Smith <morgan.j.sm...@outlook.com> Date: Tue, 2 Jan 2024 14:25:07 -0500 Subject: [PATCH] Testing: Add tests for 'org-agenda-skip-scheduled-if-deadline-is-shown' * testing/lisp/test-org-agenda.el (test-org-agenda/org-agenda-skip-scheduled-if-deadline-is-shown): New test. --- testing/lisp/test-org-agenda.el | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index 409d44192..6618fabc5 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -651,6 +651,51 @@ functions." (should (= arg-f-call-cnt 1)) (should (equal f-called-args '(1 2 3)))))) +(ert-deftest test-org-agenda/org-agenda-skip-scheduled-if-deadline-is-shown () + "Test values for `org-agenda-skip-scheduled-if-deadline-is-shown'." + (cl-assert (not org-agenda-sticky) nil "precondition violation") + (cl-assert (not (org-test-agenda--agenda-buffers)) + nil "precondition violation") + (dolist (test-time '("2017-03-06" "2017-03-10")) + (let ((org-agenda-custom-commands + '(("f" "no fluff" agenda "" + ((org-agenda-overriding-header "") + (org-agenda-todo-keyword-format "") + (org-agenda-prefix-format "%s") + (org-agenda-format-date "%d") + (org-agenda-show-all-dates nil))))) + (org-deadline-warning-days 0) + (todayp (string= test-time "2017-03-10"))) + (dolist (org-agenda-skip-scheduled-if-deadline-is-shown (list nil t 'not-today 'repeated-after-deadline)) + (org-test-at-time test-time + (org-test-agenda-with-agenda + " +* TODO task +SCHEDULED: <2017-03-06 Mon +2d> DEADLINE: <2017-03-10> +" + (should + (string-equal + (concat "06\n" + "Scheduled: task\n" + (if todayp ; We don't show repeats scheduled in the past + "" + "08\nScheduled: task\n") + "10\n" + (if (and org-agenda-skip-scheduled-if-deadline-is-shown + (not (and (not todayp) (eq org-agenda-skip-scheduled-if-deadline-is-shown 'not-today))) + (not (eq org-agenda-skip-scheduled-if-deadline-is-shown 'repeated-after-deadline))) + "" + (if todayp + "Sched. 4x: task\n" + "Scheduled: task\n")) + "Deadline: task\n" + (unless (eq org-agenda-skip-scheduled-if-deadline-is-shown 'repeated-after-deadline) + "12\nScheduled: task\n")) + (progn + (org-agenda nil "f") + (substring-no-properties (buffer-string))))) + (org-test-agenda--kill-all-agendas))))))) + (provide 'test-org-agenda) -- 2.41.0