I want to run code after adding a deadline, for example to move it forward by one day in case the deadline is early in the day, or by a few hours in case it's on a different time zone.
This attempt with a hook and a function is not called upon setting a deadline with C-d
:
(defun my-org-deadline(&rest ignore)
(interactive)
(message "Called!!!!!")
(let ((todo (org-get-todo-state))
(deadline (org-entry-get nil "DEADLINE"))
)
;; move deadline ahead by 1 day, to avoid missing it.
(when (and todo deadline)
(org-back-to-heading)
(search-forward "DEADLINE: ")
(org-timestamp-change -1 'day)
)))
(add-hook 'org-deadline #'my-org-deadline)
The function works properly if I call it, but it is not called after setting a deadline.
What is the proper way to make code run after setting a deadline?