Browse Source

Make inline task insertion deal with `org-odd-levels-only'

Also make it possible to define a default state for an inline task.

Patch by Sebastian Rose.
Carsten Dominik 11 years ago
parent
commit
5a62721822
2 changed files with 25 additions and 5 deletions
  1. 4 0
      lisp/ChangeLog
  2. 21 5
      lisp/org-inlinetask.el

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2010-04-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-inlinetask.el (org-inlinetask-defaut-state): New option.
+	(org-inlinetask-insert-task): Use `org-inlinetask-defaut-state'.
+	Obey `org-odd-levels-only'.
+
 	* org-compat.el (org-find-overlays): Use overlays-in/at.
 
 	* org.el (org-remove-empty-overlays-at)

+ 21 - 5
lisp/org-inlinetask.el

@@ -105,12 +105,28 @@ When nil, they will not be exported."
 (defvar org-complex-heading-regexp)
 (defvar org-property-end-re)
 
-(defun org-inlinetask-insert-task ()
-  "Insert an inline task."
-  (interactive)
+(defcustom org-inlinetask-defaut-state nil
+  "Non-nil means make inline tasks have a TODO keyword initially.
+This should be the state `org-inlinetask-insert-task' should use by
+default, or nil of no state should be assigned."
+  :group 'org-inlinetask
+  :type (choice
+	 (const :tag "No state" nil)
+	 (string :tag "Specific state")))
+
+(defun org-inlinetask-insert-task (&optional no-state)
+  "Insert an inline task.
+If prefix arg NO-STATE is set, irgnore `org-inlinetask-defaut-state'."
+  (interactive "P")
   (or (bolp) (newline))
-  (insert (make-string org-inlinetask-min-level ?*) " \n"
-	  (make-string org-inlinetask-min-level ?*) " END\n")
+  (let ((indent org-inlinetask-min-level))
+    (if org-odd-levels-only
+        (setq indent (- (* 2 indent) 1)))
+    (insert (make-string indent ?*)
+            (if (or no-state (not org-inlinetask-defaut-state))
+		" \n"
+	      (concat " " org-inlinetask-defaut-state " \n"))
+            (make-string indent ?*) " END\n"))
   (end-of-line -1))
 (define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)