emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] recognize HH:MM duration when sorting table rows


From: Max Mikhanosha
Subject: [O] [PATCH] recognize HH:MM duration when sorting table rows
Date: Thu, 04 Aug 2011 08:43:15 -0400
User-agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.3.50 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO)

`org-table-sort-lines' function allows one to sort the rows of a
table, by the t/T format for the column only recognizes timestamps
with a date. A patch pasted below adds recognition of HH:MM durations.

diff --git a/lisp/org.el b/lisp/org.el
index c1fd346..e65d992 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8042,11 +8042,14 @@ If WITH-CASE is non-nil, the sorting will be 
case-sensitive."
      ((= dcst ?t)
       (setq extractfun
            (lambda (x)
-             (if (or (string-match org-ts-regexp x)
-                     (string-match org-ts-regexp-both x))
-                 (org-float-time
-                  (org-time-string-to-time (match-string 0 x)))
-               0))
+             (cond ((or (string-match org-ts-regexp x)
+                        (string-match org-ts-regexp-both x))
+                    (org-float-time
+                     (org-time-string-to-time (match-string 0 x))))
+                   ;; possibly bolded hh:mm duration
+                   ((string-match "^\\*?\\([0-9]+:[0-5][0-9]\\)\\*?$" x)
+                     (org-duration-string-to-minutes (match-string 1 x)))
+                   (t 0)))
            comparefun (if (= dcst sorting-type) '< '>)))
      (t (error "Invalid sorting type `%c'" sorting-type)))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]