浏览代码

org.el: New value for `org-todo-repeat-to-state'

* lisp/org.el (org-todo-repeat-to-state): Allow `t' to use
the previous TODO state.

* doc/org.texi (Repeated tasks): Document the new optional
value of `org-todo-repeat-to-state'.
Bastien 7 年之前
父节点
当前提交
29dd9a6605
共有 2 个文件被更改,包括 21 次插入15 次删除
  1. 9 9
      doc/org.texi
  2. 12 6
      lisp/org.el

+ 9 - 9
doc/org.texi

@@ -6408,16 +6408,16 @@ Deadlines and scheduled items produce entries in the agenda when they are
 over-due, so it is important to be able to mark such an entry as completed
 over-due, so it is important to be able to mark such an entry as completed
 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
 keyword DONE, it will no longer produce entries in the agenda.  The problem
 keyword DONE, it will no longer produce entries in the agenda.  The problem
-with this is, however, that then also the @emph{next} instance of the
+with this is, however, is that then also the @emph{next} instance of the
 repeated entry will not be active.  Org mode deals with this in the following
 repeated entry will not be active.  Org mode deals with this in the following
-way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
-shift the base date of the repeating timestamp by the repeater interval, and
-immediately set the entry state back to TODO@footnote{In fact, the target
-state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property or
-the variable @code{org-todo-repeat-to-state}.  If neither of these is
-specified, the target state defaults to the first state of the TODO state
-sequence.}.  In the example above, setting the state to DONE would actually
-switch the date like this:
+way: When you try to mark such an entry as DONE (using @kbd{C-c C-t}), it
+will shift the base date of the repeating timestamp by the repeater interval,
+and immediately set the entry state back to TODO@footnote{In fact, the target
+state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property,
+the variable @code{org-todo-repeat-to-state} if it is a string, the previous
+TODO state if @code{org-todo-repeat-to-state} is @code{t} or the first state
+of the TODO state sequence.}.  In the example above, setting the state to
+DONE would actually switch the date like this:
 
 
 @example
 @example
 ** TODO Pay the rent
 ** TODO Pay the rent

+ 12 - 6
lisp/org.el

@@ -3026,13 +3026,17 @@ This option can also be set with on a per-file-basis with
 
 
 (defcustom org-todo-repeat-to-state nil
 (defcustom org-todo-repeat-to-state nil
   "The TODO state to which a repeater should return the repeating task.
   "The TODO state to which a repeater should return the repeating task.
-By default this is the first task in a TODO sequence, or the previous state
-in a TODO_TYP set.  But you can specify another task here.
-alternatively, set the :REPEAT_TO_STATE: property of the entry."
+By default this is the first task of a TODO sequence or the
+previous state of a TYPE_TODO set.  But you can specify to use
+the previous state in a TODO sequence or a string.
+
+Alternatively, you can set the :REPEAT_TO_STATE: property of the
+entry, which has precedence over this option."
   :group 'org-todo
   :group 'org-todo
   :version "24.1"
   :version "24.1"
-  :type '(choice (const :tag "Head of sequence" nil)
-		 (string :tag "Specific state")))
+  :type '(choice (const :tag "Use the previous TODO state" t)
+		 (const :tag "Use the head of the TODO sequence" nil)
+		 (string :tag "Use a specific TODO state")))
 
 
 (defcustom org-log-repeat 'time
 (defcustom org-log-repeat 'time
   "Non-nil means record moving through the DONE state when triggering repeat.
   "Non-nil means record moving through the DONE state when triggering repeat.
@@ -12782,7 +12786,9 @@ This function is run automatically after each state change to a DONE state."
 	(when (and repeat (not (zerop (string-to-number (substring repeat 1)))))
 	(when (and repeat (not (zerop (string-to-number (substring repeat 1)))))
 	  (when (eq org-log-repeat t) (setq org-log-repeat 'state))
 	  (when (eq org-log-repeat t) (setq org-log-repeat 'state))
 	  (let ((to-state (or (org-entry-get nil "REPEAT_TO_STATE" 'selective)
 	  (let ((to-state (or (org-entry-get nil "REPEAT_TO_STATE" 'selective)
-			      org-todo-repeat-to-state)))
+			      (and (stringp org-todo-repeat-to-state)
+				   org-todo-repeat-to-state)
+			      (and org-todo-repeat-to-state org-last-state))))
 	    (org-todo (cond
 	    (org-todo (cond
 		       ((and to-state (member to-state org-todo-keywords-1))
 		       ((and to-state (member to-state org-todo-keywords-1))
 			to-state)
 			to-state)