mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:07:52 +00:00
Fix toggling multiple headings with a TODO keyword
* lisp/org.el (org-toggle-item): Remove TODO keyword in each headling when changed to an item.
This commit is contained in:
parent
a8e4a393bf
commit
cd3a552ef4
24
lisp/org.el
24
lisp/org.el
|
@ -21532,8 +21532,6 @@ 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
|
||||
|
@ -21544,22 +21542,30 @@ 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))))
|
||||
(delta (max 0 (- level ref-level)))
|
||||
(todo-state (org-get-todo-state)))
|
||||
;; If current headline is less indented than the first
|
||||
;; one, set it as reference, in order to preserve
|
||||
;; subtrees.
|
||||
(when (< level ref-level) (setq ref-level level))
|
||||
(replace-match bul t t)
|
||||
;; Remove stars and TODO keyword.
|
||||
(looking-at org-todo-line-regexp)
|
||||
(delete-region (point) (or (match-beginning 3)
|
||||
(line-end-position)))
|
||||
(insert bul)
|
||||
(org-indent-line-to (+ start-ind (* delta bul-len)))
|
||||
(when (or done todo)
|
||||
;; Turn TODO keyword into a check box.
|
||||
(when todo-state
|
||||
(let* ((struct (org-list-struct))
|
||||
(old (copy-tree struct)))
|
||||
(org-list-set-checkbox (line-beginning-position)
|
||||
struct
|
||||
(if done "[X]" "[ ]"))
|
||||
(org-list-set-checkbox
|
||||
(line-beginning-position)
|
||||
struct
|
||||
(if (member todo-state org-done-keywords)
|
||||
"[X]"
|
||||
"[ ]"))
|
||||
(org-list-write-struct struct
|
||||
(org-list-parents-alist struct)
|
||||
old)))
|
||||
|
|
Loading…
Reference in a new issue