From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [PATCH] sort TODO entries more usefully Date: Sun, 25 May 2014 08:32:09 +0200 Message-ID: <87mwe65pxy.fsf@bzg.ath.cx> References: <8738fyctic.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoRyl-0006w3-DW for emacs-orgmode@gnu.org; Sun, 25 May 2014 02:32:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoRyf-0006sg-JH for emacs-orgmode@gnu.org; Sun, 25 May 2014 02:32:19 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:56430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoRyf-0006sa-BN for emacs-orgmode@gnu.org; Sun, 25 May 2014 02:32:13 -0400 Received: by mail-wi0-f175.google.com with SMTP id f8so2691521wiw.8 for ; Sat, 24 May 2014 23:32:12 -0700 (PDT) In-Reply-To: <8738fyctic.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 25 May 2014 13:33:15 +0800") 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: Eric Abrahamsen Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Eric, Eric Abrahamsen writes: > For some reason I've been sorting lots of TODOs recently, and found the > default behavior of org-sort-entries a little odd. It sorts according to > the order found in org-todo-keywords-1, which apparently just comes from > the order the keywords were scanned during setup. I don't think that's > all that useful, so the attached patch sorts first by > org-not-done-keywords vs org-done-keywords, then alphabetically. > Headings with no keywords sort "big". I don't think the alphabetical order is very useful here, and putting headlines without TODO keywords first when sorting by TODO order is counter-intuitive at least. Let me suggest the attached patch instead: it puts TODO entries, then entries without a TODO keyword, then DONE entries. Would it be an improvement? For specific needs, there is always C-c ^ f Thanks, --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-todo-sort-done-at-the-end.patch diff --git a/lisp/org.el b/lisp/org.el index dc223b4..f2963b2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8904,8 +8904,9 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'." (or (org-entry-get nil property) "")) ((= dcst ?o) (if (looking-at org-complex-heading-regexp) - (- 9999 (length (member (match-string 2) - org-todo-keywords-1))))) + (let* ((m (match-string 2)) + (s (if (member m org-done-keywords) '- '+))) + (- 99 (funcall s (length (member m org-todo-keywords-1))))))) ((= dcst ?f) (if getkey-func (progn --=-=-= Content-Type: text/plain -- Bastien --=-=-=--