This can be achieved
- by using a skip function (globally, locally, with a custom org-agenda command) or
- by changing the default behavior with an advice.
Both solutions are using the built-in function
org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
. Therefore all
org-agenda ignore timestamp settings are supported:
org-agenda-todo-ignore-with-date
, org-agenda-todo-ignore-scheduled
,
org-agenda-todo-ignore-deadlines
and org-agenda-todo-ignore-timestamp
.
I would use the skip function as it's more flexible and less prone to unexpected side effects. In addition the skip function can be applied to any org-agenda command.
Use a skip function
This can be done globally (will be applied to every agenda match) by setting org-agenda-skip-function-global
to the skip function, locally with let-binding org-agenda-skip-function
or by using a custom agenda command.
The skip function
(defun my-org-agenda-skip-if-inherited-timestamp ()
"Skip item with an inherited timestamp according to the org-agenda settings..
Uses built-in `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'."
(let ((subtree-end (save-excursion (org-end-of-subtree t)))
(ignore-item-p (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item nil)))
(while (and (org-up-heading-safe) (null ignore-item-p))
(setq ignore-item-p (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item nil)))
(when ignore-item-p
subtree-end)))
Skip globally
(setq org-agenda-skip-function-global
#'my-org-agenda-skip-if-inherited-timestamp)
;; Now the all agenda commands will ignore inherited timestamps.
(let ((org-agenda-todo-ignore-scheduled 'future))
(org-todo-list))
Skip locally
(let ((org-agenda-todo-ignore-scheduled 'future)
(org-agenda-skip-function #'my-org-agenda-skip-if-inherited-timestamp))
(org-todo-list))
Skip with custom agenda command
You can add a custom org agenda command (see help for org-agenda-custom-commands
).
Here is an example for such a custom command that uses the skip function and
ignores scheduled items in the future.
(setq org-agenda-custom-commands
'(("T" "Todo list, ignoring inherited timestamps." todo ""
((org-agenda-todo-ignore-scheduled 'future)
(org-agenda-skip-function #'my-org-agenda-skip-if-inherited-timestamp)))))
Change the default behavior with an advice
This solution uses an advice to change the default behavior of the built-in
function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
. This
will change the behavior of org-agenda-list
and org-diary
.
(defun my-org-agenda-ignore-inherited-timestamp-p (&optional end)
"Check parents of heading for timestamp and return t if found.
Uses built-in `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'."
(save-excursion
(let (ignore-item-p)
(while (and (org-up-heading-safe) (null ignore-item-p))
(setq ignore-item-p (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item nil)))
ignore-item-p)))
;; Add an advice which is called if the original function returns nil to check
;; if any parent has a timestamp.
(advice-add 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
:after-until #'my-org-agenda-ignore-inherited-timestamp-p)
;; Now the todo list will ignore inherited timestamps as well.
(let ((org-agenda-todo-ignore-scheduled 'future))
(org-todo-list))