John Sullivan <[EMAIL PROTECTED]> writes:

> Andrew Swann <[EMAIL PROTECTED]> writes:
>
>> I am using planner version 3.41 with muse version 3.11.
>>
>> I started looking at the sorting functions, since I decided that I
>> would like tasks on project pages sorted by their date.  I found
>> looking at the documentation string of planner-sort-tasks-by-date that
>> this is in fact what should be happening by default.  However, what is
>> coded is a sorting that prioritises status first, then date.  Looking
>> at the code also reveals that much of the task info structure is hard
>> coded into the function, and so does not work in combination with for
>> example planner-multi if the date link is not the last on the line.
>> Below is a fix for what I needed.  I post this in the hope that others
>> with more time, will be able to fix the other sort functions in
>> planner.el in a similar way.
>>
>
> Any chance you could send this again as a patch? 
>
> -- 
> John Sullivan

Sure.  Here it is as a patch - this first time I've tried to generate
such a thing so please let me know if the format is not ok.

Of course, this patch changes the sorting on project pages away from
what people have been getting, so it might not be popular.  Also as I
indicated above, there needs to be some similar work done on some of
the other sorting functions.

Best wishes

Andrew


--- emacs/planner/planner.el    2007-06-04 10:16:41.284200336 +0000
+++ planner.el  2007-09-10 10:05:17.460953646 +0000
@@ -2355,22 +2355,18 @@
 (defun planner-sort-tasks-by-date ()
   "Sort tasks by date, status and priority."
   (skip-chars-forward "#ABC")
-  (let ((ch (char-before))
-        status)
-    (skip-chars-forward "0123456789 ")
-    (setq status (char-after))
-    (goto-char (planner-line-end-position))
-    (skip-chars-backward "]) ")
-    (format "%1c%1c%10s"
-            (if (or (= status ?X)
+  (let* ((info (planner-current-task-info))
+        (status (string-to-char (planner-task-status info)))
+        (date (planner-task-date info))
+        (priority (string-to-char (planner-task-priority info))))
+    (format "%1c%10s%1c"
+           (if (or (= status ?X)
                     (= status ?C))
                 status ?\ )
-            ch
-            (if (= (skip-chars-backward "0123456789.")
-                   -10)
-                (buffer-substring (point)
-                                  (+ 10 (point)))
-              planner-sort-undated-tasks-equivalent))))
+           (if (null date)
+               planner-sort-undated-tasks-equivalent
+             date)
+           priority)))
 
 (defun planner-sort-tasks-by-link ()
   "Sort tasks by status, priority and link."


-- 
Andrew Swann     [EMAIL PROTECTED]     http://www.imada.sdu.dk/~swann
Department of Mathematics and Computer Science,      Tel +45 6550 2354
University of Southern Denmark, Campusvej 55,       Dept +45 6550 2387
DK-5230 Odense M, Denmark            Fax +45 6593 2691 / +45 6550 2325

_______________________________________________
Planner-el-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/planner-el-discuss

Reply via email to