From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: C-c ^ for plain lists? Why not? Date: Tue, 9 Oct 2012 09:58:11 +0200 Message-ID: <540B116A-148E-46E5-94EA-5965B206613B@gmail.com> References: <87626l6n6e.wl%jamshark70@dewdrop-world.net> <87pq4srfc6.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLUhl-00074h-Hn for emacs-orgmode@gnu.org; Tue, 09 Oct 2012 03:58:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLUhj-00063M-RN for emacs-orgmode@gnu.org; Tue, 09 Oct 2012 03:58:17 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:34360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLUhj-00062p-JW for emacs-orgmode@gnu.org; Tue, 09 Oct 2012 03:58:15 -0400 Received: by mail-wg0-f49.google.com with SMTP id gg4so3240938wgb.30 for ; Tue, 09 Oct 2012 00:58:13 -0700 (PDT) In-Reply-To: <87pq4srfc6.fsf@gmail.com> 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: Nicolas Goaziou Cc: James Harkins , emacs-orgmode@gnu.org On 8.10.2012, at 20:25, Nicolas Goaziou wrote: > Hello, > > James Harkins writes: > >> I've started to like checklists because they are a good way to keep >> account of things that have to be done, without the individual items >> being entered into the agenda (and thus transferred to MobileOrg). >> >> But I'm running into the limitation that plain lists can't be sorted >> *by their checklist status*. You can sort alphabetically, numerically >> or by time or function. So, I guess I have to write a lisp function to >> do it... but I don't have time to do that right now, but I need to >> sort the list now... >> >> Valid feature request? > > There are four states: checked box, unchecked box, transitory box and no > box at all. I can't see an order that should be prevalent over others. I would think that checked - transitionary - unchecked - no box is a pretty decent default. > > As such, I think it is a specific use-case that should be treated by "f" > or "F" sorting key. Such a sorting function could be an interesting Org > Hacks addition. Playing with this idea I noticed that the sorting function did not accept their additional arguments like sorting-key and get key-function in they way they should. So I patched them, to make the following work in the current master: (defun org-sort-list-by-checkbox-type () "Sort list items according to Checkbox state." (interactive) (org-sort-list nil ?f (lambda () (if (looking-at org-list-full-item-re) (cdr (assoc (match-string 3) '(("[X]" . 1) ("[-]" . 2) ("[ ]" . 3) (nil . 4)))) 4)))) Depending on how you want the sorting, you can change ?f to ?F to reverse, and/or you can change the numbers in the alist to modify the sort order in any way you like. HTH! - Carsten