emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Mikhanosha <max@openchat.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] recognize HH:MM duration when sorting table rows
Date: Thu, 04 Aug 2011 08:43:15 -0400	[thread overview]
Message-ID: <87oc05pct8.wl%max@openchat.com> (raw)

`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	other threads:[~2011-08-04 12:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 12:43 Max Mikhanosha [this message]
2011-08-16 14:57 ` [PATCH] recognize HH:MM duration when sorting table rows Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oc05pct8.wl%max@openchat.com \
    --to=max@openchat.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).