Browse Source

org-list.el (org-sort-list): Implement sorting by "checked" status for check lists

* org-list.el (org-sort-list): Implement sorting by "checked"
status for check lists.

* org.texi (Plain lists): Add index entry for sorting plain
list.  Document sorting by checked status for check lists.
Bastien Guerry 11 years ago
parent
commit
f80e262967
2 changed files with 12 additions and 5 deletions
  1. 3 1
      doc/org.texi
  2. 9 4
      lisp/org-list.el

+ 3 - 1
doc/org.texi

@@ -1832,9 +1832,11 @@ This command also cycles bullet styles when the cursor in on the bullet or
 anywhere in an item line, details depending on
 anywhere in an item line, details depending on
 @code{org-support-shift-select}.
 @code{org-support-shift-select}.
 @kindex C-c ^
 @kindex C-c ^
+@cindex sorting, of plain list
 @item C-c ^
 @item C-c ^
 Sort the plain list.  You will be prompted for the sorting method:
 Sort the plain list.  You will be prompted for the sorting method:
-numerically, alphabetically, by time, or by custom function.
+numerically, alphabetically, by time, by checked status for check lists,
+or by a custom function.
 @end table
 @end table
 
 
 @node Drawers, Blocks, Plain lists, Document Structure
 @node Drawers, Blocks, Plain lists, Document Structure

+ 9 - 4
lisp/org-list.el

@@ -2799,13 +2799,14 @@ optional argument WITH-CASE, the sorting considers case as well.
 
 
 The command prompts for the sorting type unless it has been given
 The command prompts for the sorting type unless it has been given
 to the function through the SORTING-TYPE argument, which needs to
 to the function through the SORTING-TYPE argument, which needs to
-be a character, \(?n ?N ?a ?A ?t ?T ?f ?F).  Here is the precise
-meaning of each character:
+be a character, \(?n ?N ?a ?A ?t ?T ?f ?F ?c ?C).  Here is the
+detailed meaning of each character:
 
 
 n   Numerically, by converting the beginning of the item to a number.
 n   Numerically, by converting the beginning of the item to a number.
 a   Alphabetically.  Only the first line of item is checked.
 a   Alphabetically.  Only the first line of item is checked.
 t   By date/time, either the first active time stamp in the entry, if
 t   By date/time, either the first active time stamp in the entry, if
     any, or by the first inactive one.  In a timer list, sort the timers.
     any, or by the first inactive one.  In a timer list, sort the timers.
+c   By \"checked\" status of a check list.
 
 
 Capital letters will reverse the sort order.
 Capital letters will reverse the sort order.
 
 
@@ -2827,7 +2828,7 @@ ignores hidden links."
 	  (or sorting-type
 	  (or sorting-type
 	      (progn
 	      (progn
 		(message
 		(message
-		 "Sort plain list: [a]lpha  [n]umeric  [t]ime  [f]unc   A/N/T/F means reversed:")
+		 "Sort plain list: [a]lpha  [n]umeric  [t]ime  [f]unc  [c]hecked  A/N/T/F/C means reversed:")
 		(read-char-exclusive))))
 		(read-char-exclusive))))
 	 (getkey-func
 	 (getkey-func
 	  (or getkey-func
 	  (or getkey-func
@@ -2844,7 +2845,8 @@ ignores hidden links."
 	     (sort-func (cond
 	     (sort-func (cond
 			 ((= dcst ?a) 'string<)
 			 ((= dcst ?a) 'string<)
 			 ((= dcst ?f) compare-func)
 			 ((= dcst ?f) compare-func)
-			 ((= dcst ?t) '<)))
+			 ((= dcst ?t) '<)
+			 ((= dcst ?c) 'string<)))
 	     (next-record (lambda ()
 	     (next-record (lambda ()
 			    (skip-chars-forward " \r\t\n")
 			    (skip-chars-forward " \r\t\n")
 			    (or (eobp) (beginning-of-line))))
 			    (or (eobp) (beginning-of-line))))
@@ -2875,6 +2877,9 @@ ignores hidden links."
 							     (point-at-eol) t)))
 							     (point-at-eol) t)))
 		      (org-time-string-to-seconds (match-string 0)))
 		      (org-time-string-to-seconds (match-string 0)))
 		     (t (org-float-time now))))
 		     (t (org-float-time now))))
+		   ((= dcst ?c) (or (and (stringp (match-string 1))
+					 (match-string 1))
+				    ""))
 		   ((= dcst ?f)
 		   ((= dcst ?f)
 		    (if getkey-func
 		    (if getkey-func
 			(let ((value (funcall getkey-func)))
 			(let ((value (funcall getkey-func)))