From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cecil Westerhof Subject: Re: Check checkbox and move to end of list Date: Thu, 23 Jan 2014 01:46:05 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c16f5e01879504f09891d5 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W68Qq-0007kn-Cf for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 19:46:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W68Qo-0005Zc-Vu for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 19:46:08 -0500 Received: from mail-qc0-x232.google.com ([2607:f8b0:400d:c01::232]:51927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W68Qo-0005ZY-LQ for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 19:46:06 -0500 Received: by mail-qc0-f178.google.com with SMTP id m20so1587646qcx.23 for ; Wed, 22 Jan 2014 16:46:05 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --001a11c16f5e01879504f09891d5 Content-Type: text/plain; charset=ISO-8859-1 2014/1/23 Cecil Westerhof > I also think it would be a good idea to change > (org-list-send-item item 'end struct) > to a call to a function. I think it would be useful to have a function to > send a item to the end (or begin) of a list. > I know have the following: (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)))))) (defun dcbl-move-item-to-begin-of-list (&optional item) (interactive) (save-excursion (when item (goto-char item)) (org-list-send-item (line-beginning-position) 'begin (org-list-struct))) (previous-line)) (defun dcbl-move-item-to-end-of-list (&optional item) (interactive) (save-excursion (when item (goto-char item)) (org-list-send-item (line-beginning-position) 'end (org-list-struct)))) (global-set-key [?\C-c ?\M-a] 'dcbl-move-item-to-begin-of-list) (global-set-key [?\C-c ?\M-c] 'dcbl-check-checkbox-and-move-to-end) (global-set-key [?\C-c ?\M-e] 'dcbl-move-item-to-end-of-list) -- Cecil Westerhof --001a11c16f5e01879504f09891d5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2014= /1/23 Cecil Westerhof <cldwesterhof@gmail.com>
I also think it would be a go= od idea to change
=A0=A0=A0 (org-list-send-item item 'end struct)
to a call to a funct= ion. I think it would be useful to have a function to send a item to the en= d (or begin) of a list.

I know have the following:
(defun dcbl-check-checkbox-and-move-to-end ()=
=A0 (interactive)
=A0 (save-excursion
=A0=A0=A0 (let* ((struct=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (org-list-struct))
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 (struct-old=A0=A0=A0=A0=A0=A0=A0=A0 (copy-tree struct))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (item=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (line-beginning-position))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (item-chec= kbox-type (org-list-get-checkbox item struct)))
=A0=A0=A0=A0=A0 (if (not= item-checkbox-type)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (message "No check= box found")
=A0=A0=A0=A0=A0=A0=A0 (if (string-equal item-checkbox-type "[X]")=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (message "Checkbox already check= ed")
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (org-list-set-checkbox item struct= "[X]")
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (org-list-write-struct str= uct (org-list-parents-alist struct) struct-old)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (dcbl-move-item-to-end-of-list item))))))
(defun dcbl-move-item-to-begin-of-list (&optional item)
=A0 (inter= active)
=A0 (save-excursion
=A0=A0=A0 (when item
=A0=A0=A0=A0=A0 (= goto-char item))
=A0=A0=A0 (org-list-send-item (line-beginning-position)= 'begin (org-list-struct)))
=A0 (previous-line))

(defun dcbl-move-item-to-end-of-list (&opti= onal item)
=A0 (interactive)
=A0 (save-excursion
=A0=A0=A0 (when i= tem
=A0=A0=A0=A0=A0 (goto-char item))
=A0=A0=A0 (org-list-send-item (= line-beginning-position) 'end (org-list-struct))))



(global-set-key [?\C-c ?\M-a]=A0=A0=A0 'dcbl-move-item-to-b= egin-of-list)
(global-set-key [?\C-c ?\M-c]=A0=A0=A0 'dcbl-check-che= ckbox-and-move-to-end)
(global-set-key [?\C-c ?\M-e]=A0=A0=A0 'dcbl-= move-item-to-end-of-list)
=A0
--
Cecil Westerhof
--001a11c16f5e01879504f09891d5--