summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2014-01-12 23:02:42 (GMT)
committer Bastien Guerry <bzg@altern.org>2014-01-12 23:02:42 (GMT)
commit213c2a6aa057b993b0dd461c50a27034fb553faf (patch)
tree5c9566197e16429da5daaad553a4ff973e99edc2
parentb9e1dd8ff8e3b398f9a37f16e3ef26d93411a52a (diff)
downloadorg-mode-213c2a6aa057b993b0dd461c50a27034fb553faf.zip
org-mode-213c2a6aa057b993b0dd461c50a27034fb553faf.tar.gz
org.el (org-toggle-item): Handle TODO and DONE keywords
* org.el (org-toggle-item): When an entry has a TODO or a DONE keyword, add an empty or a checked checkbox.
-rw-r--r--lisp/org.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/org.el b/lisp/org.el
index bb0f0fd..31ce31a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20662,6 +20662,8 @@ With a prefix argument ARG, change the region in a single item."
((org-at-heading-p)
(let* ((bul (org-list-bullet-string "-"))
(bul-len (length bul))
+ (done (org-entry-is-done-p))
+ (todo (org-entry-is-todo-p))
;; Indentation of the first heading. It should be
;; relative to the indentation of its parent, if any.
(start-ind (save-excursion
@@ -20672,6 +20674,7 @@ With a prefix argument ARG, change the region in a single item."
;; Level of first heading. Further headings will be
;; compared to it to determine hierarchy in the list.
(ref-level (org-reduced-level (org-outline-level))))
+ (when (or done todo) (org-todo ""))
(while (< (point) end)
(let* ((level (org-reduced-level (org-outline-level)))
(delta (max 0 (- level ref-level))))
@@ -20681,6 +20684,13 @@ With a prefix argument ARG, change the region in a single item."
(when (< level ref-level) (setq ref-level level))
(replace-match bul t t)
(org-indent-line-to (+ start-ind (* delta bul-len)))
+ (if (or done todo)
+ (let* ((struct0 (org-list-struct))
+ (struct (org-list-struct))
+ (parents (org-list-parents-alist struct))
+ (item (car (assoc (point) struct))))
+ (org-list-set-checkbox item struct (if done "[X]" "[ ]"))
+ (org-list-struct-apply-struct struct struct0)))
;; Ensure all text down to END (or SECTION-END) belongs
;; to the newly created item.
(let ((section-end (save-excursion