2014/1/23 Cecil Westerhof <cldwester...@gmail.com>

> The following function does (mostly) what I want:
> (defun dcbl-check-checkbox-and-move-to-end ()
>   (interactive)
>   (save-excursion
>     (let* ((struct             (org-list-struct))
>            (struct-old         (copy-tree struct))
>            (item               (line-beginning-position))
>            (item-checkbox-type (org-list-get-checkbox item struct)))
>       (if (not item-checkbox-type)
>           (message "No checkbox found")
>         (if (string-equal item-checkbox-type "[X]")
>             (message "Checkbox already checked")
>           (org-list-set-checkbox item struct "[X]")
>           (org-list-write-struct struct (org-list-parents-alist struct)
> struct-old)
>           (org-list-send-item item 'end struct))))))
>

Update of the count in the parent did not go correctly always. This code
does the update correct. (Only the last command is appended.)
(defun dcbl-check-checkbox-and-move-to-end ()
  (interactive)
  (save-excursion
    (let* ((struct             (org-list-struct))
           (struct-old         (copy-tree struct))
           (item               (line-beginning-position))
           (item-checkbox-type (org-list-get-checkbox item struct)))
      (if (not item-checkbox-type)
          (message "No checkbox found")
        (if (string-equal item-checkbox-type "[X]")
            (message "Checkbox already checked")
          (org-list-set-checkbox item struct "[X]")
          (org-list-write-struct struct (org-list-parents-alist struct)
struct-old)
          (dcbl-move-item-to-end-of-list item)
          (org-update-statistics-cookies nil))))))


-- 
Cecil Westerhof

Reply via email to