0

I defined RECURRING as a special keyword for tasks that are repeated periodically. When I mark the task as done with C-c C-t d the keyword switches to the default TODO keyword. I want it however to keep the RECURRING keyword. How to achieve this?

Minimal example:

#+TODO: TODO(t!) RECURRING(R!) | DONE(d!)
#+STARTUP: logdrawer
#+STARTUP: indent

# Task before marking it as done with C-c C-t d 
* RECURRING go shopping 
SCHEDULED: <2023-06-07 Wed ++7d>
:LOGBOOK:
- State "RECURRING"  from              [2023-06-07 Wed 12:49]
:END:

# Task after marking it as done with C-c C-t d
# Keyword changed to TODO 
* TODO reply mail 
DEADLINE: <2023-06-18 Sun ++7d>
:PROPERTIES:
:LAST_REPEAT: [2023-06-07 Wed 13:00]
:END:
:LOGBOOK:
- State "DONE"       from "RECURRING"  [2023-06-07 Wed 13:00]
- State "RECURRING"  from              [2023-06-07 Wed 12:49]
:END:

I could define the keywords in the following order, to prevent this behaviour: #+TODO: RECURRING(R!) TODO(t!) | DONE(d!) After marking the task as done, the keyword is reset to RECURRING. However, I don't like this 'hack' because I sometimes use Shift+Rightarrowkey on a heading without a keyword and want the TODO state to appear first. Otherwise the log will save RECURRING as first state, although the task was never meant to be a recurring task. See the following example:

#+TODO: RECURRING(R!) TODO(t!) | DONE(d!)
#+STARTUP: logdrawer
#+STARTUP: indent

* TODO task with previously no keyword, cycling with Shift+Rightarrowkey
:LOGBOOK:
- State "TODO"       from "RECURRING"  [2023-06-07 Wed 13:09]
- State "RECURRING"  from              [2023-06-07 Wed 13:08]
:END:
2
  • 2
    Have you read TODO Extensions in the manual? In particular, how exactly did you define RECURRING? You might want to look into the subsections Multiple sets in one file and Per file keywords.
    – NickD
    Jun 6, 2023 at 22:14
  • Thanks for your comment @NickD. I added a minimal example of my setup and more explanation. I also had a look at the manual again, but could not find a solution to my problem. Thanks for your help!
    – GNUmon
    Jun 7, 2023 at 11:25

1 Answer 1

1

I found the answer in a footnote in the manual.

It says:

In fact, the target state is taken from, in this sequence, the ‘REPEAT_TO_STATE’ property, the variable org-todo-repeat-to-state if it is a string, the previous TODO state if org-todo-repeat-to-state is t, or the first state of the TODO state sequence.

So in the example above you could use a property, perhaps setting it up in a capture template to achieve the desired behavior or you could just set the following in the emacs configuration: (setq org-todo-repeat-to-state "RECURRING")

The minimal example from above is then:

#+TODO: TODO(t!) RECURRING(R!) | DONE(d!)
#+STARTUP: logdrawer
#+STARTUP: indent

# using property 
* RECURRING go shopping 
:PROPERTIES:
:REPEAT_TO_STATE: RECURRING
:LAST_REPEAT: [2023-06-07 Wed 14:23]
:END:
SCHEDULED: <2023-06-21 Wed ++7d>
:LOGBOOK:
- State "DONE"       from "RECURRING"  [2023-06-07 Wed 14:23]
- State "DONE"       from "RECURRING"  [2023-06-07 Wed 14:23]
- State "RECURRING"  from              [2023-06-07 Wed 12:49]
:END:

# using (setq org-todo-repeat-to-state "RECURRING") in emacs configuration 
* RECURRING reply mail 
DEADLINE: <2023-07-02 Sun ++7d>
:PROPERTIES:
:LAST_REPEAT: [2023-06-07 Wed 14:19]
:END:
:LOGBOOK:
- State "DONE"       from "RECURRING"  [2023-06-07 Wed 14:19]
- State "DONE"       from "RECURRING"  [2023-06-07 Wed 14:19]
- State "RECURRING"  from              [2023-06-07 Wed 14:19]
:END:

Your Answer

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

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