Hi Eric,

Eric Abrahamsen <e...@ericabrahamsen.net> 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,

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

Reply via email to