I'm trying to get org-agenda to behave a bit more like a paper day planner, and have it only show deadlines on the day that they're due, rather than carrying them forward when they're overdue. So far, I've created a custom org-agenda view as follows:

(defun org-agenda-skip-deadline-if-not-today ()
    (let ((subtree-end (save-excursion (org-end-of-subtree t)))
            (time-to-days (org-time-string-to-time (org-entry-get nil "DEADLINE"))))
          (now (time-to-days (current-time))))
      (and deadline-day
           (not (= deadline-day now))

(setq org-agenda-custom-commands
  '(("b" agenda "Today's Deadlines"
    ((org-agenda-span 'day)
     (org-agenda-skip-function '(org-agenda-skip-deadline-if-not-today))
     (org-agenda-entry-types '(:deadline))
     (org-agenda-overriding-header "Today's Deadlines")))))

However, this only shows the agenda entries for today. What I would like to do is pass into org-agenda-skip-deadline-if-not-today the date range of the current agenda view, and have it exclude subtrees whose deadline lies outside of that range.

Is it possible to do that with elisp? I've looked at the org manual for custom agenda views, but I haven't been able to find out get the date range for the current agenda view.

  • 1
    Try replacing now with org-starting-day in (not (= deadline-day now)). org-starting-day is defined in the agenda buffer. So, whether it works depends on which buffer is active when the command is executed. – Tobias Jul 2 '19 at 22:40
  • Oh, it looks like org-starting-day is what I need, along with org-agenda-span. Could you please put your comment in as an answer, so I can accept it? – quanticle Jul 3 '19 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.