emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
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 02:07:06 +0100	[thread overview]
Message-ID: <CAG-LmmA=RkztZnk=D2xFRPUXyeVaJSTKbnvi-abe-UzAMkSMrw@mail.gmail.com> (raw)
In-Reply-To: <CAG-LmmC_5-rJBQNvnRbPV-VG0Wsxq8HCfUzD3Hhumma7uqMr+Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

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

> (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

[-- Attachment #2: Type: text/html, Size: 1989 bytes --]

  reply	other threads:[~2014-01-23  1:07 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 [this message]
2014-01-23 19:51 ` Cecil Westerhof

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG-LmmA=RkztZnk=D2xFRPUXyeVaJSTKbnvi-abe-UzAMkSMrw@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).