From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Move to item to the bottom Date: Thu, 30 Jun 2011 20:55:16 +0200 Message-ID: <878vsjb14b.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcMOa-00080h-0v for emacs-orgmode@gnu.org; Thu, 30 Jun 2011 14:55:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QcMOX-0003VN-UW for emacs-orgmode@gnu.org; Thu, 30 Jun 2011 14:55:23 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:45590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcMOX-0003VH-DE for emacs-orgmode@gnu.org; Thu, 30 Jun 2011 14:55:21 -0400 Received: by wyg36 with SMTP id 36so2166087wyg.0 for ; Thu, 30 Jun 2011 11:55:20 -0700 (PDT) In-Reply-To: (Marcelo de Moraes Serpa's message of "Thu, 30 Jun 2011 11:13:03 -0500") 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: Marcelo de Moraes Serpa Cc: Org Mode Hello, Marcelo de Moraes Serpa 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