emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] recognize HH:MM duration when sorting table rows
@ 2011-08-04 12:43 Max Mikhanosha
  2011-08-16 14:57 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Max Mikhanosha @ 2011-08-04 12:43 UTC (permalink / raw)
  To: emacs-orgmode

`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)))
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] recognize HH:MM duration when sorting table rows
  2011-08-04 12:43 [PATCH] recognize HH:MM duration when sorting table rows Max Mikhanosha
@ 2011-08-16 14:57 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2011-08-16 14:57 UTC (permalink / raw)
  To: Max Mikhanosha; +Cc: emacs-orgmode

Hi Max,

Max Mikhanosha <max@openchat.com> writes:

> `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.

Thanks a lot -- I'm willing to apply this patch.  

Could you reformat it with git format-patch and include a proper
ChangeLog entry?  

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-16 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04 12:43 [PATCH] recognize HH:MM duration when sorting table rows Max Mikhanosha
2011-08-16 14:57 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).