瀏覽代碼

Make the repeater target state configurable

The target state can now be fixed locally with the REPEAT_TO_STATE
property, or globally with the variable `org-todo-repeat-to-state'.

This was a request by John Wiegley.
Carsten Dominik 15 年之前
父節點
當前提交
32340d0389
共有 4 個文件被更改,包括 39 次插入14 次删除
  1. 5 0
      doc/ChangeLog
  2. 15 11
      doc/org.texi
  3. 3 0
      lisp/ChangeLog
  4. 16 3
      lisp/org.el

+ 5 - 0
doc/ChangeLog

@@ -1,3 +1,8 @@
+2010-04-12  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Repeated tasks): Document that the user can determine
+	the target state.
+
 2010-04-07  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.texi (LaTeX and PDF export): Add a footnote about xetex.

+ 15 - 11
doc/org.texi

@@ -5375,17 +5375,21 @@ from that time.  If you need both a repeater and a special warning period in
 a deadline entry, the repeater should come first and the warning period last:
 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
 
-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 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 with this is, however, that then also the
-@emph{next} instance of the 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.  In the example above, setting the state to DONE would
-actually switch the date like this:
+@vindex org-todo-repeat-to-state
+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
+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
+with this is, however, that then also the @emph{next} instance of the
+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:
 
 @example
 ** TODO Pay the rent

+ 3 - 0
lisp/ChangeLog

@@ -2,6 +2,9 @@
 
 	* org.el (org-export-latex-default-packages-alist): Remove
 	microtype package.
+	(org-todo-repeat-to-state): New variable.
+	(org-auto-repeat-maybe): Allow user-selected target states.
+	(org-default-properties): Add the new property REPEAT_TO_STATE.
 
 2010-04-09  Carsten Dominik  <carsten.dominik@gmail.com>
 

+ 16 - 3
lisp/org.el

@@ -2184,6 +2184,15 @@ When nil, the state change notes will be ordered according to time."
   :group 'org-progress
   :type 'boolean)
 
+(defcustom org-todo-repeat-to-state nil
+  "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."
+  :group 'org-todo
+  :type '(choice (const :tag "Head of sequence" nil)
+		 (string :tag "Specific state")))
+
 (defcustom org-log-repeat 'time
   "Non-nil means record moving through the DONE state when triggering repeat.
 An auto-repeating task is immediately switched back to TODO when
@@ -10835,10 +10844,14 @@ This function is run automatically after each state change to a DONE state."
 	 (org-log-done nil)
 	 (org-todo-log-states nil)
 	 (nshiftmax 10) (nshift 0)
-	 re type n what ts time)
+	 re type n what ts time to-state)
     (when repeat
       (if (eq org-log-repeat t) (setq org-log-repeat 'state))
-      (org-todo (if (eq interpret 'type) last-state head))
+      (setq to-state (or (org-entry-get nil "REPEAT_TO_STATE")
+			 org-todo-repeat-to-state))
+      (unless (and to-state (member to-state org-todo-keywords-1))
+	(setq to-state (if (eq interpret 'type) last-state head)))
+      (org-todo to-state)
       (org-entry-put nil "LAST_REPEAT" (format-time-string
 					(org-time-stamp-format t t)))
       (when org-log-repeat
@@ -12663,7 +12676,7 @@ but in some other way.")
     "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
     "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
     "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE"
-    "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER"
+    "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
     "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
   "Some properties that are used by Org-mode for various purposes.
 Being in this list makes sure that they are offered for completion.")