emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Move to item to the bottom


From: Nicolas Goaziou
Subject: Re: [O] Move to item to the bottom
Date: Thu, 30 Jun 2011 20:55:16 +0200

Hello,

Marcelo de Moraes Serpa <address@hidden> writes:

> It'd be nice if we could just send an item to the bottom of a list. Useful
> when reviewing a long list and putting the next actions in the top. Is there
> a way to do that with org currently?

Not heavily tested, but something like the following snippet should
work:

#+begin_src emacs-lisp
(defun ngz-move-item-at-bottom ()
  "Move item at point at the bottom of the list.
Note that the item will be become the last item of the top-level
list, whatever its original indentation was."
  (interactive)
  (if (not (org-at-item-p))
      (error "Not in a list")
    (let* ((item (point-at-bol))
           (struct (org-list-struct))
           (top-item (org-list-get-top-point struct))
           (end (org-list-get-item-end item struct))
           (bullet (org-list-get-bullet item struct))
           (body (org-trim
                  (buffer-substring (progn (looking-at (concat "[ \t]*" bullet))
                                           (match-end 0))
                                    end)))
           (prevs (org-list-prevs-alist struct))
           (last-top-level-item (org-list-get-last-item top-item struct prevs))
           (ins-point (save-excursion (goto-char last-top-level-item)
                                      (point-at-eol)))
           (org-M-RET-may-split-line nil))
      (if (= item last-top-level-item)
          (error "Item is already at the bottom of the list")
        (save-excursion (org-list-insert-item ins-point struct prevs nil body))
        (delete-region item end)))))
#+end_src

Regards,

-- 
Nicolas Goaziou



reply via email to

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