9

When processing my tasks in org-mode I use a custom view that displays my unscheduled/undeadlined TODOs, as well as the next two days of my days-agenda. I would like to use SCHEDULED dates as the start date for a task, i.e., this task cannot even be started until the SCHEDULED date and time have past. With this in mind, a task that is scheduled for 5pm tomorrow is not only useless to me today, it is equally useless tomorrow until after 5pm. Is there any way to hide SCHEDULED tasks from TODO lists and agendas if it is before their due date and time?

I am aware of the settings (setq org-agenda-todo-ignore-scheduled 'future) and (setq org-agenda-tags-todo-honor-ignore-options t). However, the former seems only to apply to the global todo list, and the latter is for tags-todo search; neither setting seems to have any effect on the daily/weekly agenda. In addition, the settings mentioned above only seem to consider the scheduled date not the scheduled time, so even in the global todo list, items scheduled for tomorrow at noon will be visible from tomorrow after midnight on.

I assume this is possible because the agenda is date and time aware, but I have not been able to find a solution.

0

1 Answer 1

6

See the doc-strings for org-agenda-skip-function and/or org-agenda-skip-function-global. http://orgmode.org/manual/Special-agenda-views.html

;;; Entry in `org-agenda-custom-commands':
;;  (org-agenda-skip-function '(org-agenda-skip-if-scheduled-later))
(defun org-agenda-skip-if-scheduled-later ()
"If this function returns nil, the current match should not be skipped.
Otherwise, the function must return a position from where the search
should be continued."
  (ignore-errors
    (let ((subtree-end (save-excursion (org-end-of-subtree t)))
          (scheduled-seconds
            (time-to-seconds
              (org-time-string-to-time
                (org-entry-get nil "SCHEDULED"))))
          (now (time-to-seconds (current-time))))
       (and scheduled-seconds
            (>= scheduled-seconds now)
            subtree-end))))

The example in the org-mode manual uses the point end of the subtree as the value for the org-agenda search to continue after evaluating the skip function. This is presumably because said skip function may move point. In this example, point does not need to be moved to determine whether a scheduled entry is greater than or equal to the current time. It may be possible to save a split second [multiplied by each entry] by using (point) instead of (save-excursion (org-end-of-subtree t)) -- and change the wording of subtree-end in both places with the word point so as to avoid confusion. [However, @lawlist has not actually tested that hypothesis with this example.] Since users who read this thread may move point as part of their own custom skip function, @lawlist is leaving the textbook example that uses point at the end of the subtree. The goal is to prevent a never ending loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.