7

I have some item in an org buffer marked as TODO and having a scheduled timestamp:

* TODO do something
  SCHEDULED: <2014-11-02 Sun>

How do I cause the SCHEDULED timestamp to be removed when I move this item to the 'waiting' state?

  • Why do you want it to be removed? Is it for the purpose of not showing up on the agenda? – Malabarba Oct 27 '14 at 14:42
  • I'd like it removed because by default I don't schedule WAITING items. But I'd like it to still show up on the Agenda if SCHEDULED because sometimes I do schedule them (e.g. to check in after X days of WAITING). – mankoff Oct 27 '14 at 15:02
  • Yes, it's for the purpose of not showing up on the agenda - Generally it's some task I did work on, and now am waiting for a response to an email. So transitioning it to 'WAITING' indicates that I can't work on it now, and want the scheduled timestamp to leave (Of course, if I later add a scheduled timestamp to it, I want it to show up again). – Nathaniel Flath Oct 27 '14 at 15:26
3

Maybe something like this (tested briefly from buffer and agenda)

(defun rasmus/remove-schedule ()
  "Remove SCHEDULED-cookie is switching state to WAITING."
  (save-excursion
(and (equal (org-get-todo-state) "WAITING")
     (org-get-scheduled-time (point))
     (when (search-forward-regexp org-scheduled-time-regexp nil t)
       (or (delete-region (match-beginning 0) (match-end 0)) t))
     (get-buffer "*Org Agenda*")
     (with-current-buffer "*Org Agenda*"
       (org-agenda-redo)))))

(add-hook 'org-after-todo-state-change-hook
     'rasmus/remove-schedule)
1

If you're doing this so that WAITING items don't show up in the agenda buffer, I'd like to suggest an alternative.

You can define WAITING to be a DONE-type keyword. These can easily be configured to not display in the agenda, even when they have a schedule. You can do that globally with this:

(setq org-todo-keywords '((sequence "TODO" "|" "WAITING" "DONE")))

Or on a per-file basis with this header:

#+SEQ_TODO: TODO | WAITING DONE

Then, to have these items not display in the agenda, just make sure you set:

(setq org-agenda-skip-scheduled-if-done t)

Finally, if you occasionally need a WAITING item to be displayed in the agenda, set a DEADLINE on it instead of a SCHEDULE. The display of deadlines is controlled by a different variable (org-agenda-skip-deadline-if-done ), so they will still display in the agenda.

  • 1
    If you use done logging this will create a done log for waiting, which might be a bit confusing. – ceving Dec 4 '14 at 8:09

Your Answer

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

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