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 02:07:06 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6d7e0a2c7a5804f098dc40 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W68lA-0003OQ-0Y for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 20:07:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W68l9-0002dY-1t for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 20:07:07 -0500 Received: from mail-qc0-x230.google.com ([2607:f8b0:400d:c01::230]:49719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W68l8-0002dT-TI for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 20:07:06 -0500 Received: by mail-qc0-f176.google.com with SMTP id e16so1627330qcx.7 for ; Wed, 22 Jan 2014 17:07:06 -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 --047d7b6d7e0a2c7a5804f098dc40 Content-Type: text/plain; charset=ISO-8859-1 2014/1/23 Cecil Westerhof > (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)))) > There was not enough error checking. Better is: (defun dcbl-move-item-to-begin-of-list (&optional item) (interactive) (let ((list nil)) (save-excursion (when item (goto-char item)) (setq list (org-list-struct)) (if (not list) (message "Not in a list") (org-list-send-item (line-beginning-position) 'begin list))) (when list (previous-line)))) (defun dcbl-move-item-to-end-of-list (&optional item) (interactive) (let ((list nil)) (save-excursion (when item (goto-char item)) (setq list (org-list-struct)) (if (not list) (message "Not in a list") (org-list-send-item (line-beginning-position) 'end list))))) -- Cecil Westerhof --047d7b6d7e0a2c7a5804f098dc40 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2014= /1/23 Cecil Westerhof <cldwesterhof@gmail.com>
(def= un dcbl-move-item-to-begin-of-list (&optional item)
=A0 (interactive)
= =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))))

There was = not enough error checking. Better is:
(defun dcbl-move-item-to-begin-of-= list (&optional item)
=A0 (interactive)
=A0 (let ((list nil))
=A0=A0=A0 (save-excursion
= =A0=A0=A0=A0=A0 (when item
=A0=A0=A0=A0=A0=A0=A0 (goto-char item))
= =A0=A0=A0=A0=A0 (setq list (org-list-struct))
=A0=A0=A0=A0=A0 (if (not l= ist)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (message "Not in a list")
=A0=A0=A0=A0=A0=A0=A0 (org-list-send-item (line-beginning-position) 'be= gin list)))
=A0=A0=A0 (when list
=A0=A0=A0=A0=A0 (previous-line))))
(defun dcbl-move-item-to-end-of-list (&optional item)
=A0 (int= eractive)
=A0 (let ((list nil))
=A0=A0=A0 (save-excursion
=A0=A0=A0=A0=A0 (when item
=A0=A0=A0=A0=A0= =A0=A0 (goto-char item))
=A0=A0=A0=A0=A0 (setq list (org-list-struct))=A0=A0=A0=A0=A0 (if (not list)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (message &q= uot;Not in a list")
=A0=A0=A0=A0=A0=A0=A0 (org-list-send-item (line= -beginning-position) 'end list)))))

--
Cecil Westerhof
--047d7b6d7e0a2c7a5804f098dc40--