*** old-org.el	2009-01-04 03:01:50.000000000 -0500
--- org.el	2009-02-07 15:13:57.000000000 -0500
***************
*** 1409,1414 ****
--- 1409,1426 ----
    :tag "Org Progress"
    :group 'org-time)
  
+ (defvar org-todo-interpretation-widgets
+    '(
+        (:tag "Sequence (cycling hits every state)" sequence)
+        (:tag "Type     (cycling directly to DONE)" type))
+    
+    "The available interpretation symbols for customizing
+ `org-todo-keywords'.
+ Interested libraries should add to this list." )
+ (defvar org-todo-normal-interpretations 
+    '(sequence)
+    "" )
+ 
  (defcustom org-todo-keywords '((sequence "TODO" "DONE"))
    "List of TODO entry keyword sequences and their interpretation.
  \\<org-mode-map>This is a list of sequences.
***************
*** 1458,1465 ****
  		  (cons
  		   (choice
  		    :tag "Interpretation"
! 		    (const :tag "Sequence (cycling hits every state)" sequence)
! 		    (const :tag "Type     (cycling directly to DONE)" type))
  		   (repeat
  		    (string :tag "Keyword"))))))
  
--- 1470,1487 ----
  		  (cons
  		   (choice
  		    :tag "Interpretation"
! 		      ;;Quick and dirty way to see
! 		      ;;`org-todo-interpretations'.  This takes the
! 		      ;;place of item arguments
! 		      :convert-widget
! 		      (lambda (widget)
! 			 (widget-put widget 
! 			    :args (mapcar 
! 				     #'(lambda (x)
! 					  (widget-convert 
! 					     (cons 'const x)))
! 				     org-todo-interpretation-widgets))
! 			 widget))
  		   (repeat
  		    (string :tag "Keyword"))))))
  
***************
*** 3025,3031 ****
      (org-set-local 'org-file-properties nil)
      (org-set-local 'org-file-tags nil)
      (let ((re (org-make-options-regexp
! 	       '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS"
  		 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
  		 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE")))
  	  (splitre "[ \t]+")
--- 3047,3053 ----
      (org-set-local 'org-file-properties nil)
      (org-set-local 'org-file-tags nil)
      (let ((re (org-make-options-regexp
! 	       '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "CHOOSE_TODO" "COLUMNS"
  		 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
  		 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE")))
  	  (splitre "[ \t]+")
***************
*** 3052,3057 ****
--- 3074,3081 ----
  	      (push (cons 'sequence (org-split-string value splitre)) kwds))
  	     ((equal key "TYP_TODO")
  	      (push (cons 'type (org-split-string value splitre)) kwds))
+ 	     ((equal key "CHOOSE_TODO")
+ 	      (push (cons 'choose (org-split-string value splitre)) kwds))
  	     ((equal key "TAGS")
  	      (setq tags (append tags (org-split-string value splitre))))
  	     ((equal key "COLUMNS")
***************
*** 3133,3138 ****
--- 3157,3168 ----
        (setq kwds (nreverse kwds))
        (let (inter kws kw)
  	(while (setq kws (pop kwds))
+ 	  (let
+ 	     ((kws
+ 		 (or
+ 		    (run-hook-with-args-until-success
+ 		       'org-todo-setup-filter-hook kws) 
+ 		    kws)))
  	     (setq inter (pop kws) sep (member "|" kws)
  		kws0 (delete "|" (copy-sequence kws))
  		kwsa nil
***************
*** 3154,3160 ****
  				      '((:endgroup))))
  		hw (car kws1)
  		dws (if sep (org-remove-keyword-keys (cdr sep)) (last kws1))
! 		tail (list inter hw (car dws) (org-last dws)))
  	  (add-to-list 'org-todo-heads hw 'append)
  	  (push kws1 org-todo-sets)
  	  (setq org-done-keywords (append org-done-keywords dws nil))
--- 3184,3190 ----
  				 '((:endgroup))))
  		hw (car kws1)
  		dws (if sep (org-remove-keyword-keys (cdr sep)) (last kws1))
! 		tail (list inter hw (car dws) (org-last dws))))
  	  (add-to-list 'org-todo-heads hw 'append)
  	  (push kws1 org-todo-sets)
  	  (setq org-done-keywords (append org-done-keywords dws nil))
***************
*** 4934,4944 ****
        (org-back-to-heading)
        (outline-previous-heading)
        (looking-at org-todo-line-regexp))
      (if (or arg
  	    (not (match-beginning 2))
  	    (member (match-string 2) org-done-keywords))
! 	(insert (car org-todo-keywords-1) " ")
!       (insert (match-string 2) " "))
      (when org-provide-todo-statistics
        (org-update-parent-todo-statistics))))
  
--- 4964,4983 ----
        (org-back-to-heading)
        (outline-previous-heading)
        (looking-at org-todo-line-regexp))
+     (let*
+        ((new-mark-x
  	   (if (or arg
  		  (not (match-beginning 2))
  		  (member (match-string 2) org-done-keywords))
! 	      (car org-todo-keywords-1)
! 	      (match-string 2)))
! 	  (new-mark
! 	     (or
! 		(run-hook-with-args-until-success
! 		   'org-todo-get-default-hook new-mark-x nil)
! 		new-mark-x)))
!        (insert new-mark " "))
!      
      (when org-provide-todo-statistics
        (org-update-parent-todo-statistics))))
  
***************
*** 8190,8195 ****
--- 8229,8246 ----
  :from  previous state (keyword as a string), or nil
  :to    new state (keyword as a string), or nil")
  
+ (defvar org-todo-setup-filter-hook nil 
+    "Hook for functions that pre-filter todo specs.
+ 
+ Each function takes a todo spec and returns either `nil' or the spec
+ transformed into canonical form." )
+ 
+ (defvar org-todo-get-default-hook nil
+    "Hook for functions that get a default item for todo.
+ 
+ Each function takes arguments (NEW-MARK OLD-MARK) and returns either
+ `nil' or a string to be used for the todo mark." )
+ 
  (defvar org-agenda-headline-snapshot-before-repeat)
  (defun org-todo (&optional arg)
    "Change the TODO state of an item.
***************
*** 8285,8291 ****
  		     ((null member) (or head (car org-todo-keywords-1)))
  		     ((equal this final-done-word) nil) ;; -> make empty
  		     ((null tail) nil) ;; -> first entry
! 		     ((eq interpret 'sequence)
  		      (car tail))
  		     ((memq interpret '(type priority))
  		      (if (eq this-command last-command)
--- 8336,8342 ----
  		     ((null member) (or head (car org-todo-keywords-1)))
  		     ((equal this final-done-word) nil) ;; -> make empty
  		     ((null tail) nil) ;; -> first entry
! 		     ((memq interpret org-todo-normal-interpretations)
  		      (car tail))
  		     ((memq interpret '(type priority))
  		      (if (eq this-command last-command)
***************
*** 8294,8299 ****
--- 8345,8354 ----
  			    (or done-word (car org-done-keywords))
  			  nil)))
  		     (t nil)))
+ 	     (state (or 
+ 		       (run-hook-with-args-until-success
+ 			  'org-todo-get-default-hook state last-state) 
+ 		       state))
  	     (next (if state (concat " " state " ") " "))
  	     (change-plist (list :type 'todo-state-change :from this :to state
  				 :position startpos))
