[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Remove scheduled date when switch TODO states

From: David Maus
Subject: Re: [Orgmode] Re: Remove scheduled date when switch TODO states
Date: Mon, 22 Feb 2010 23:19:55 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.1.92 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Matt Lundin wrote:
>Nathaniel Flath <address@hidden> writes:

>> I have a todo state, PENDING, that I organize tasks that I cannot
>> perform immediately.  Is there a way to configure org-todoconfigure so
>> that when a task is switched to PENDING, if it has a scheduled date
>> that date is removed?

>You could use the hook org-after-todo-state-change-hook. E.g.

>--8<---------------cut here---------------start------------->8---
>(defun my-org-pending-remove-deadline ()
>  (when (equal (org-entry-get nil "TODO") "PENDING")
>    (org-remove-timestamp-with-keyword org-deadline-string)))

>(add-hook 'org-after-todo-state-change-hook 'my-org-pending-remove-deadline)
>--8<---------------cut here---------------end--------------->8---

You can actually skip the `org-entry-get' as "The new state (a string
with a TODO keyword, or nil) is available in the Lisp variable

| (defun my-org-pending-remove-deadline ()
|   (when (string= state "PENDING")
|     (org-remove-timestamp-with-keyword org-deadline-string)))

Another solution: use `org-trigger-hook' and `org-schedule':

| (defvar dmj/org-pending-keywords '("PENDING")
|   "List of keywords denoting pending state of an headline.")
| (defun dmj/org-remove-schedule-when-pending (plist)
|   "Remove schedule when todo state changes to pending."
|   (let ((type (plist-get plist :type))
|       (to (plist-get plist :to)))
|     (when (and (eq type 'todo-state-change)
|              (member to dmj/org-pending-keywords))
|       (org-schedule 'remove))))

 -- David

[1] http://orgmode.org/worg/org-configs/org-hooks.php#sec-1.13
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden

Attachment: pgpRGfbFapVo1.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]