emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] summarize timestamps in column view
@ 2013-06-09  0:01 Pedro Silva
  2013-06-30 21:59 ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Silva @ 2013-06-09  0:01 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Pedro Silva

* 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

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

* Re: [PATCH] summarize timestamps in column view
  2013-06-09  0:01 [PATCH] summarize timestamps in column view Pedro Silva
@ 2013-06-30 21:59 ` Bastien
  2013-06-30 23:27   ` Pedro Silva
  0 siblings, 1 reply; 3+ messages in thread
From: Bastien @ 2013-06-30 21:59 UTC (permalink / raw)
  To: Pedro Silva; +Cc: emacs-orgmode

Hi Pedro,

Pedro Silva <psilva+git@pedrosilva.pt> writes:

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

Looks good, thanks!

It hardly counts as a tiny change, though, as I count 25 lines...
I'm afraid the patch is larger than what we can accept without
paperwork.  Would you mind signing the FSF copyright assignment
(or telling me if you did so already for Emacs)?

  http://orgmode.org/cgit.cgi/org-mode.git/plain/request-assign-future.txt

That'll leave some time so that someone else can test the patch
and report about it :)

Thanks in advance!

-- 
 Bastien

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

* Re: [PATCH] summarize timestamps in column view
  2013-06-30 21:59 ` Bastien
@ 2013-06-30 23:27   ` Pedro Silva
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Silva @ 2013-06-30 23:27 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

Bastien <bzg@gnu.org> writes:

> It hardly counts as a tiny change, though, as I count 25 lines...
> I'm afraid the patch is larger than what we can accept without
> paperwork.  Would you mind signing the FSF copyright assignment
> (or telling me if you did so already for Emacs)?

I don't mind assigning copyright to FSF at all. I've not done so until now.

>   http://orgmode.org/cgit.cgi/org-mode.git/plain/request-assign-future.txt
>
> That'll leave some time so that someone else can test the patch
> and report about it :)

Sounds good. I'll email <assign@gnu.org> after I write this. Should I
revive this thread when the assignment is acknowledged?

Thanks for looking at the patch,
-- 
Pedro

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

end of thread, other threads:[~2013-06-30 23:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-09  0:01 [PATCH] summarize timestamps in column view Pedro Silva
2013-06-30 21:59 ` Bastien
2013-06-30 23:27   ` Pedro Silva

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