Browse Source

TODO entries: Control over when selecting a state is treated as state change.

This commit introduces two new variables:

- org-treat-insert-todo-heading-as-state-change

  Default is nil.  When set to t, adding a new TODO item will be done
  by adding an item and the executing an "official" state change which
  potentially will trigger state logging.

- org-treat-S-cursor-todo-seletion-as-state-change

  Default is t.  When set to nil, selecting a TODO state with
  S-left/right will not trigger logging, only selecting a new state
  with `C-c C-t'.  I actually like this a lot and would even consider
  making this the default.
Carsten Dominik 16 years ago
parent
commit
a18546c360
4 changed files with 50 additions and 5 deletions
  1. 5 0
      doc/ChangeLog
  2. 6 2
      doc/org.texi
  3. 11 0
      lisp/ChangeLog
  4. 28 3
      lisp/org.el

+ 5 - 0
doc/ChangeLog

@@ -1,3 +1,8 @@
+2009-05-27  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Structure editing, TODO basics): Document new
+	variables.
+
 2009-05-21  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-05-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.texi (Column attributes): Document new colciew operators.
 	* org.texi (Column attributes): Document new colciew operators.

+ 6 - 2
doc/org.texi

@@ -958,7 +958,9 @@ current heading, the new heading is placed after the body instead of before
 it.  This command works from anywhere in the entry.
 it.  This command works from anywhere in the entry.
 @kindex M-S-@key{RET}
 @kindex M-S-@key{RET}
 @item M-S-@key{RET}
 @item M-S-@key{RET}
-Insert new TODO entry with same level as current heading.
+@vindex org-treat-insert-todo-heading-as-state-change
+Insert new TODO entry with same level as current heading.  See also the
+variable @code{org-treat-insert-todo-heading-as-state-change}.
 @kindex C-S-@key{RET}
 @kindex C-S-@key{RET}
 @item C-S-@key{RET}
 @item C-S-@key{RET}
 Insert new TODO entry with same level as current heading.  Like
 Insert new TODO entry with same level as current heading.  Like
@@ -3193,12 +3195,14 @@ more information.
 
 
 @kindex S-@key{right}
 @kindex S-@key{right}
 @kindex S-@key{left}
 @kindex S-@key{left}
+@vindex org-treat-S-cursor-todo-seletion-as-state-change
 @item S-@key{right}
 @item S-@key{right}
 @itemx S-@key{left}
 @itemx S-@key{left}
 Select the following/preceding TODO state, similar to cycling.  Useful
 Select the following/preceding TODO state, similar to cycling.  Useful
 mostly if more than two TODO states are possible (@pxref{TODO
 mostly if more than two TODO states are possible (@pxref{TODO
 extensions}).  See also @ref{Conflicts} for a discussion of the interaction
 extensions}).  See also @ref{Conflicts} for a discussion of the interaction
-with @code{shift-selection-mode}.
+with @code{shift-selection-mode}.  See also the variable
+@code{org-treat-S-cursor-todo-seletion-as-state-change}.
 @kindex C-c C-v
 @kindex C-c C-v
 @kindex C-c / t
 @kindex C-c / t
 @cindex sparse tree, for TODO
 @cindex sparse tree, for TODO

+ 11 - 0
lisp/ChangeLog

@@ -1,3 +1,14 @@
+2009-05-27  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-treat-insert-todo-heading-as-state-change)
+	(org-treat-S-cursor-todo-seletion-as-state-change): New
+	variables.
+	(org-insert-todo-heading): Honor
+	`org-treat-insert-todo-heading-as-state-change'.
+	(org-shiftright, org-shiftleft): Honor
+	`org-treat-S-cursor-todo-seletion-as-state-change'.
+	(org-inhibit-logging): New variable.
+
 2009-05-23  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-05-23  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-agenda.el (org-remove-subtree-entries-from-agenda): Reduce
 	* org-agenda.el (org-remove-subtree-entries-from-agenda): Reduce

+ 28 - 3
lisp/org.el

@@ -1817,6 +1817,22 @@ to change is while Emacs is running is through the customize interface."
   :group 'org-todo
   :group 'org-todo
   :type 'boolean)
   :type 'boolean)
 
 
+(defcustom org-treat-insert-todo-heading-as-state-change nil
+  "Non-nil means, inserting a TODO heading is treated as state change.
+So when the command \\[org-insert-todo-heading] is used, state change
+logging will apply if appropriate.  When nil, the new TODO item will
+be inserted directly, and no logging will take place."
+  :group 'org-todo
+  :type 'boolean)
+
+(defcustom org-treat-S-cursor-todo-seletion-as-state-change t
+  "Non-nil means, switching TODO states with S-cursor counts as state change.
+This is the default behavior.  However, setting this to nil allows a
+convenient way to select a TODO state and bypass any logging associated
+with that."
+  :group 'org-todo
+  :type 'boolean)
+
 (defcustom org-todo-state-tags-triggers nil
 (defcustom org-todo-state-tags-triggers nil
   "Tag changes that should be triggered by TODO state changes.
   "Tag changes that should be triggered by TODO state changes.
 This is a list.  Each entry is
 This is a list.  Each entry is
@@ -3811,6 +3827,7 @@ This variable is set by `org-before-change-function'.
   "Mode hook for Org-mode, run after the mode was turned on.")
   "Mode hook for Org-mode, run after the mode was turned on.")
 (defvar org-inhibit-startup nil)        ; Dynamically-scoped param.
 (defvar org-inhibit-startup nil)        ; Dynamically-scoped param.
 (defvar org-agenda-keep-modes nil)      ; Dynamically-scoped param.
 (defvar org-agenda-keep-modes nil)      ; Dynamically-scoped param.
+(defvar org-inhibit-logging nil)        ; Dynamically-scoped param.
 (defvar org-table-buffer-is-an nil)
 (defvar org-table-buffer-is-an nil)
 (defconst org-outline-regexp "\\*+ ")
 (defconst org-outline-regexp "\\*+ ")
 
 
@@ -5495,7 +5512,9 @@ state (TODO by default).  Also with prefix arg, force first state."
 	   new-mark-x)))
 	   new-mark-x)))
       (beginning-of-line 1)
       (beginning-of-line 1)
       (and (looking-at "\\*+ ") (goto-char (match-end 0))
       (and (looking-at "\\*+ ") (goto-char (match-end 0))
-	   (insert new-mark " ")))
+	   (if org-treat-insert-todo-heading-as-state-change
+	       (org-todo new-mark)
+	     (insert new-mark " "))))
     (when org-provide-todo-statistics
     (when org-provide-todo-statistics
       (org-update-parent-todo-statistics))))
       (org-update-parent-todo-statistics))))
 
 
@@ -9120,6 +9139,7 @@ Each function takes arguments (NEW-MARK OLD-MARK) and returns either
 `nil' or a string to be used for the todo mark." )
 `nil' or a string to be used for the todo mark." )
 
 
 (defvar org-agenda-headline-snapshot-before-repeat)
 (defvar org-agenda-headline-snapshot-before-repeat)
+
 (defun org-todo (&optional arg)
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
   "Change the TODO state of an item.
 The state of an item is given by a keyword at the start of the heading,
 The state of an item is given by a keyword at the start of the heading,
@@ -9278,6 +9298,7 @@ For calling through lisp, arg is also interpreted in the following way:
 				(not (member this org-done-keywords))))
 				(not (member this org-done-keywords))))
 	  (and logging (org-local-logging logging))
 	  (and logging (org-local-logging logging))
 	  (when (and (or org-todo-log-states org-log-done)
 	  (when (and (or org-todo-log-states org-log-done)
+		     (not org-inhibit-logging)
 		     (not (memq arg '(nextset previousset))))
 		     (not (memq arg '(nextset previousset))))
 	    ;; we need to look at recording a time and note
 	    ;; we need to look at recording a time and note
 	    (setq dolog (or (nth 1 (assoc state org-todo-log-states))
 	    (setq dolog (or (nth 1 (assoc state org-todo-log-states))
@@ -14475,7 +14496,9 @@ Depending on context, this does one of the following:
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
    ((and (not (eq org-support-shift-select 'always))
    ((and (not (eq org-support-shift-select 'always))
 	 (org-on-heading-p))
 	 (org-on-heading-p))
-    (org-call-with-arg 'org-todo 'right))
+    (let ((org-inhibit-logging
+	   (not org-treat-S-cursor-todo-seletion-as-state-change)))
+      (org-call-with-arg 'org-todo 'right)))		       
    ((or (and org-support-shift-select
    ((or (and org-support-shift-select
 	     (not (eq org-support-shift-select 'always))
 	     (not (eq org-support-shift-select 'always))
 	     (org-at-item-bullet-p))
 	     (org-at-item-bullet-p))
@@ -14505,7 +14528,9 @@ Depending on context, this does one of the following:
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
    ((and (not (eq org-support-shift-select 'always))
    ((and (not (eq org-support-shift-select 'always))
 	 (org-on-heading-p))
 	 (org-on-heading-p))
-    (org-call-with-arg 'org-todo 'left))
+    (let ((org-inhibit-logging
+	   (not org-treat-S-cursor-todo-seletion-as-state-change)))
+      (org-call-with-arg 'org-todo 'left)))
    ((or (and org-support-shift-select
    ((or (and org-support-shift-select
 	     (not (eq org-support-shift-select 'always))
 	     (not (eq org-support-shift-select 'always))
 	     (org-at-item-bullet-p))
 	     (org-at-item-bullet-p))