From: Cecil Westerhof <cldwesterhof@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Check checkbox and move to end of list
Date: Thu, 23 Jan 2014 20:51:14 +0100 [thread overview]
Message-ID: <CAG-LmmBicgeT-Kd8gWN2vPPwDks=ANEFKS+bPKHsi1=+W3FDpA@mail.gmail.com> (raw)
In-Reply-To: <CAG-LmmBMJvP3X32QepOb=+nEsbEO+JWkbWk2XZ_YuYB-r8h4Gw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1685 bytes --]
2014/1/23 Cecil Westerhof <cldwesterhof@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
[-- Attachment #2: Type: text/html, Size: 2437 bytes --]
prev parent reply other threads:[~2014-01-23 19:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-22 23:50 Check checkbox and move to end of list Cecil Westerhof
2014-01-23 0:46 ` Cecil Westerhof
2014-01-23 1:07 ` Cecil Westerhof
2014-01-23 19:51 ` Cecil Westerhof [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAG-LmmBicgeT-Kd8gWN2vPPwDks=ANEFKS+bPKHsi1=+W3FDpA@mail.gmail.com' \
--to=cldwesterhof@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.