From mboxrd@z Thu Jan 1 00:00:00 1970 From: Max Mikhanosha Subject: [PATCH] recognize HH:MM duration when sorting table rows Date: Thu, 04 Aug 2011 08:43:15 -0400 Message-ID: <87oc05pct8.wl%max@openchat.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([140.186.70.92]:34135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoxGi-0005KQ-Ca for emacs-orgmode@gnu.org; Thu, 04 Aug 2011 08:43:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoxGg-0002hc-95 for emacs-orgmode@gnu.org; Thu, 04 Aug 2011 08:43:20 -0400 Received: from p84-72.acedsl.com ([66.114.84.72]:57541 helo=momoland.openchat.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoxGg-0002hI-5N for emacs-orgmode@gnu.org; Thu, 04 Aug 2011 08:43:18 -0400 Received: from momoland.openchat.com (localhost [IPv6:::1]) by momoland.openchat.com (Postfix) with ESMTP id 6E466E6C13 for ; Thu, 4 Aug 2011 08:43:15 -0400 (EDT) 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: emacs-orgmode@gnu.org `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)))