emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Pedro Silva <psilva+git@pedrosilva.pt>
To: emacs-orgmode@gnu.org
Cc: Pedro Silva <psilva+git@pedrosilva.pt>
Subject: [PATCH] summarize timestamps in column view
Date: Sun,  9 Jun 2013 01:01:11 +0100	[thread overview]
Message-ID: <1370736071-1857-1-git-send-email-psilva+git@pedrosilva.pt> (raw)

* org-colview.el (org-columns-compile-map):
(org-columns-number-to-string):
(org-columns-string-to-number): Handle timestamp summaries.

* org.texi (Column attributes): Document timestamp summaries.

TINYCHANGE
---
 contrib/lisp/org-colview-xemacs.el | 11 ++++++++++-
 doc/org.texi                       |  3 +++
 lisp/org-colview.el                | 11 ++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/contrib/lisp/org-colview-xemacs.el b/contrib/lisp/org-colview-xemacs.el
index 63c0238..c2cff84 100644
--- a/contrib/lisp/org-colview-xemacs.el
+++ b/contrib/lisp/org-colview-xemacs.el
@@ -901,7 +901,12 @@ around it."
     ("@mean" mean_age
      (lambda (&rest x) (/ (apply '+ x) (float (length x))))
      (lambda (x) (- org-columns-time x)))
-    ("est+" estimate org-estimate-combine))
+    ("est+" estimate org-estimate-combine)
+    ("<min" timestamp min org-time-string-to-seconds)
+    ("<max" timestamp min org-time-string-to-seconds)
+    ("<mean" timestamp
+     (lambda (&rest x) (/ (apply '+ x) (float (length x))))
+     org-time-string-to-seconds))
   "Operator <-> format,function,calc  map.
 Used to compile/uncompile columns format and completing read in
 interactive function `org-columns-new'.
@@ -1190,6 +1195,9 @@ Don't set this, this is meant for dynamic scoping.")
 (defun org-columns-number-to-string (n fmt &optional printf)
   "Convert a computed column number to a string value, according to FMT."
   (cond
+   ((memq fmt '(timestamp))
+    (format-time-string
+     (or printf (car org-time-stamp-formats)) (seconds-to-time n)))
    ((memq fmt '(estimate)) (org-estimate-print n printf))
    ((not (numberp n)) "")
    ((memq fmt '(add_times max_times min_times mean_times))
@@ -1218,6 +1226,7 @@ Don't set this, this is meant for dynamic scoping.")
   "Convert a column value to a number that can be used for column computing."
   (if s
       (cond
+       ((memq fmt '(timestamp)) s)
        ((memq fmt '(min_age max_age mean_age))
 	(cond ((string= s "") org-columns-time)
 	      ((string-match
diff --git a/doc/org.texi b/doc/org.texi
index 6d5eca0..8b1c49d 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5497,6 +5497,9 @@ optional.  The individual parts have the following meaning:
                 @{@@min@}    @r{Minimum age (in days/hours/mins/seconds).}
                 @{@@max@}    @r{Maximum age (in days/hours/mins/seconds).}
                 @{@@mean@}   @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
+                @{<min@}    @r{Minimum timestamp.}
+                @{<max@}    @r{Maximum timestamp.}
+                @{<mean@}   @r{Arithmetic mean of timestamps.}
                 @{est+@}    @r{Add low-high estimates.}
 @end example
 
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index a98deec..f52cb25 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -761,7 +761,12 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column format."
     ("@mean" mean_age
      (lambda (&rest x) (/ (apply '+ x) (float (length x))))
      (lambda (x) (- org-columns-time x)))
-    ("est+" estimate org-estimate-combine))
+    ("est+" estimate org-estimate-combine)
+    ("<min" timestamp min org-time-string-to-seconds)
+    ("<max" timestamp min org-time-string-to-seconds)
+    ("<mean" timestamp
+     (lambda (&rest x) (/ (apply '+ x) (float (length x))))
+     org-time-string-to-seconds))
   "Operator <-> format,function,calc  map.
 Used to compile/uncompile columns format and completing read in
 interactive function `org-columns-new'.
@@ -1055,6 +1060,9 @@ Don't set this, this is meant for dynamic scoping.")
 (defun org-columns-number-to-string (n fmt &optional printf)
   "Convert a computed column number to a string value, according to FMT."
   (cond
+   ((memq fmt '(timestamp))
+    (format-time-string
+     (or printf (car org-time-stamp-formats)) (seconds-to-time n)))
    ((memq fmt '(estimate)) (org-estimate-print n printf))
    ((not (numberp n)) "")
    ((memq fmt '(add_times max_times min_times mean_times))
@@ -1083,6 +1091,7 @@ Don't set this, this is meant for dynamic scoping.")
   "Convert a column value to a number that can be used for column computing."
   (if s
       (cond
+       ((memq fmt '(timestamp)) s)
        ((memq fmt '(min_age max_age mean_age))
         (cond ((string= s "") org-columns-time)
               ((string-match
-- 
1.8.3

             reply	other threads:[~2013-06-09  0:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09  0:01 Pedro Silva [this message]
2013-06-30 21:59 ` [PATCH] summarize timestamps in column view Bastien
2013-06-30 23:27   ` Pedro Silva

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=1370736071-1857-1-git-send-email-psilva+git@pedrosilva.pt \
    --to=psilva+git@pedrosilva.pt \
    --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).