emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Check checkbox and move to end of list


From: Cecil Westerhof
Subject: Re: [O] Check checkbox and move to end of list
Date: Thu, 23 Jan 2014 20:51:14 +0100

2014/1/23 Cecil Westerhof <address@hidden>
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

[Prev in Thread] Current Thread [Next in Thread]