Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-08-28 Thread James TD Smith
Hi Manish,

On 2009-08-27 21:20:53(+0530), Manish wrote:
 On Sat, Jul 18, 2009 at 3:05 PM, Bastien wrote:
 
  This patch is just a workaround, though. I think we should have a way of
  adding more than one custom function, as Mikael Fornius suggested when
  sending his first patch.
 
  Let's see what's Carsten take on this.

 This is/was a very interesting idea. Any thoughts if this would go in? Or did
 it already go in and I missed it?

Carsten and I agreed offlist not to apply my original patch, and that I would
work on a better implementation using column summaries. I've got it mostly
working.

--
|-James TD Smith-email/ahktenz...@mohorovi.cc-|


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-08-27 Thread Manish
On Sat, Jul 18, 2009 at 3:05 PM, Bastien wrote:
 Hi James,

 this small patch against current org-colview.el lets you have a custom
 function for computing a summary of a property and displaying it in
 the column.

 To compute the time since the timestamp, you can use this patch and some
 of your code like this:

 --8---cut here---start-8---
 (setq org-columns-custom-summary-function
      'my-org-compute-since)

 (defun org-time-since (time)
  Get the number of days since `time'
  (time-to-number-of-days
  (time-since (apply 'encode-time
                     (org-parse-time-string time)

 (defun my-org-compute-since (rest values)
  Eval elapsted days since the entry's timestamp.
  (let* ((ts (org-entry-get (point) TIMESTAMP)))
    (when ts (org-time-since ts
 --8---cut here---end---8---

 This patch is just a workaround, though.  I think we should have a way
 of adding more than one custom function, as Mikael Fornius suggested
 when sending his first patch.

 Let's see what's Carsten take on this.


This is/was a very interesting idea.  Any thoughts if this would go
in?  Or did it already go in and I missed it?

-- 
Manish


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-07-18 Thread Bastien
Hi James, 

this small patch against current org-colview.el lets you have a custom
function for computing a summary of a property and displaying it in
the column.

To compute the time since the timestamp, you can use this patch and some
of your code like this:

--8---cut here---start-8---
(setq org-columns-custom-summary-function 
  'my-org-compute-since)

(defun org-time-since (time)
  Get the number of days since `time'
  (time-to-number-of-days 
  (time-since (apply 'encode-time
 (org-parse-time-string time)

(defun my-org-compute-since (rest values)
  Eval elapsted days since the entry's timestamp.
  (let* ((ts (org-entry-get (point) TIMESTAMP)))
(when ts (org-time-since ts
--8---cut here---end---8---

This patch is just a workaround, though.  I think we should have a way
of adding more than one custom function, as Mikael Fornius suggested
when sending his first patch.

Let's see what's Carsten take on this.

Thanks!

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index d132bf6..b312d35 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -698,20 +698,30 @@ around it.
 		(org-columns-display-here (cdr x)))
 	  cache)
 
+(defcustom org-columns-custom-summary-function nil
+  A user-defined custom summary function.
+This function takes one argument: a list containing the values of
+all children for the summarized property.  This function should
+return a number.
+  :group 'org-link
+  :type 'function)
+
 (defvar org-columns-compile-map
-  '((none  none  +)
-(: add_times +)
-(+ add_numbers   +)
-($ currency  +)
-(X checkbox  +)
-(X/checkbox-n-of-m   +)
-(X%checkbox-percent  +)
-(max   max_numbers   max)
-(min   min_numbers   min)
-(mean  mean_numbers  (lambda (rest x) (/ (apply '+ x) (float (length x)
-(:max  max_times max)
-(:min  min_times min)
-(:mean mean_times(lambda (rest x) (/ (apply '+ x) (float (length x))
+  '((none   none  +)
+(:  add_times +)
+(+  add_numbers   +)
+($  currency  +)
+(X  checkbox  +)
+(X/ checkbox-n-of-m   +)
+(X% checkbox-percent  +)
+(maxmax_numbers   max)
+(minmin_numbers   min)
+(mean   mean_numbers  (lambda (rest x) (/ (apply '+ x) (float (length x)
+(:max   max_times max)
+(:min   min_times min)
+(:mean  mean_times(lambda (rest x) (/ (apply '+ x) (float (length x)
+(custom custom_function   (lambda (rest x) 
+  (funcall org-columns-custom-summary-function x
   Operator - format,function map.
 Used to compile/uncompile columns format and completing read in
 interactive function org-columns-new.)

-- 
 Bastien
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-07-17 Thread Bastien
Hi James, 

sorry for the delay.  As I said, I will let Carsten decides about this
patch.  While I like the idea of displaying this information in column
view, I'm unsure whether it's relevant to add another special property.

Two arguments: (1) this special property, contrary to other ones, is a
_relative_ property.  The information it displays in the column view is
not displayed in the subtree, it is dynamically computed when displaying
the column.  So it is a special special property. (2) The 2nd argument
is that, it would be more useful to have a custom summary-type mechanism
rather than adding too many special properties.  Displaying SINCE could
be done by such a mechanism.  

What do you think?

James TD Smith ahktenz...@mohorovi.cc writes:

 These give the elapsed time since the TIMESTAMP and TIMESTAMP_IA
 properties. This value is in days, as a floating point number.

 For display in column view, this is converted to a human-readable time
 interval in the form 8d 02h 12m 22s.
 ---
  lisp/ChangeLog  |   18 --
  lisp/org-colview.el |   36 
  lisp/org.el |   23 ++-
  3 files changed, 58 insertions(+), 19 deletions(-)

 diff --git a/lisp/ChangeLog b/lisp/ChangeLog
 index 351731d..348ade3 100755
 --- a/lisp/ChangeLog
 +++ b/lisp/ChangeLog
 @@ -1,3 +1,17 @@
 +2009-07-12  James TD Smith  ahktenz...@mohorovi.cc
 +
 + * org-colview.el (org-format-time-period): Formats a time in
 + fractional days as days, hours, mins, seconds.
 + (org-columns-display-here): Add special handling for SINCE and
 + SINCE_IA to format for display.
 +
 + * org.el (org-time-since): Add a function to get the time since an
 + org timestamp.
 + (org-entry-properties): Add two new special properties: SINCE and
 + SINCE_IA. These give the time since any active or inactive
 + timestamp in an entry.
 + (org-special-properties): Add SINCE, SINCE_IA.
 +
  2009-07-08  Carsten Dominik  carsten.domi...@gmail.com
  
   * org-clock.el (org-clock-goto): Find hidden headlines as well.
 @@ -561,7 +575,7 @@
   `org-export-push-to-kill-ring'.
  
   * org-exp.el (org-export-show-temporary-export-buffer): New
 - option. 
 + option.
  
   * org-latex.el (org-export-as-latex): Use
   `org-export-show-temporary-export-buffer'.
 @@ -2861,7 +2875,7 @@
   (org-agenda-change-all-lines, org-tags-sparse-tree)
   (org-time-string-to-absolute, org-small-year-to-year)
   (org-link-escape): Re-apply changes accidentially overwritten
 - by last commit to Emacs.
 + by last commit to Emacs
  
  2008-11-23  Carsten Dominik  carsten.domi...@gmail.com
  
 diff --git a/lisp/org-colview.el b/lisp/org-colview.el
 index 7633b5b..6a89849 100644
 --- a/lisp/org-colview.el
 +++ b/lisp/org-colview.el
 @@ -190,18 +190,19 @@ This is the compiled version of the format.)
 (length property))
   f (format %%-%d.%ds |  width width)
   val (or (cdr ass) )
 - modval (or (and org-columns-modify-value-for-display-function
 - (functionp
 -  org-columns-modify-value-for-display-function)
 - (funcall
 -  org-columns-modify-value-for-display-function
 -  title val))
 -(if (equal property ITEM)
 -(if (org-mode-p)
 -(org-columns-cleanup-item
 - val org-columns-current-fmt-compiled)
 -  (org-agenda-columns-cleanup-item
 -   val pl cphr org-columns-current-fmt-compiled)
 + modval (cond ((and org-columns-modify-value-for-display-function
 +(functionp
 + org-columns-modify-value-for-display-function))
 +   (funcall org-columns-modify-value-for-display-function
 +title val))
 +((equal property ITEM)
 + (if (org-mode-p)
 + (org-columns-cleanup-item
 +  val org-columns-current-fmt-compiled)
 +   (org-agenda-columns-cleanup-item
 +val pl cphr org-columns-current-fmt-compiled)))
 +((or (equal property SINCE) (equal property 
 SINCE_IA))
 + (org-format-time-period val
(setq s2 (org-columns-add-ellipses (or modval val) width))
(setq string (format f s2))
;; Create the overlay
 @@ -1388,6 +1389,17 @@ This will add overlays to the date lines, to show the 
 summary for each day.
  (equal (nth 4 a) (nth 4 fm)))
 (org-columns-compute (car fm)))
  
 +(defun org-format-time-period (interval)
 +  (if (stringp interval)
 +  
 +(let* ((days (floor interval))
 +

Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-07-17 Thread James TD Smith
Hi Bastien

On 2009-07-17 18:55:01(+0200), Bastien wrote:
 sorry for the delay.  As I said, I will let Carsten decides about this
 patch.  While I like the idea of displaying this information in column
 view, I'm unsure whether it's relevant to add another special property.

 Two arguments: (1) this special property, contrary to other ones, is a
 _relative_ property.  The information it displays in the column view is
 not displayed in the subtree, it is dynamically computed when displaying
 the column.  So it is a special special property. (2) The 2nd argument
 is that, it would be more useful to have a custom summary-type mechanism
 rather than adding too many special properties.  Displaying SINCE could
 be done by such a mechanism.

 What do you think?

Actually, I've been thinking the same thing. When I wrote the patch adding a new
property looked like the easiest way to get what I wanted, but it's somewhat
limited. It would be useful to be able to use a property for the creation time
of an entry, rather than putting an inactive timestamp in the entry. There's
also the problem of being dependent on the order of the contents of the entry
(the TIMESTAMP and TIMESTAMP_IA special properties return the first timestamp in
the entry), so it only does the right thing if the LOGBOOK and PROPERTIES
drawers are at the top of the entry and in that order.

Having a column view operator for calculating time since would avoid this
problem and be much more flexible. I've been looking at the changes Mikael
Fornius' patch to org-columnview added, and I think I can add a new operator for
this fairly easily.

I still might want to add another special property, for the latest clocked time
for an entry. That way I can have a column for the creation time (stored in a
property) and a column for the last time I worked on the entry.

James

--
|-James TD Smith-email/ahktenz...@mohorovi.cc-|


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-07-14 Thread Bastien
Hi James,

welcome back.  Carsten is on vacation for three weeks and I'm
maintaining Org in the meanwhile.

I won't take the decision of adding new special properties without
asking him so I don't apply this patch for now.  But I will use your
patch for a while and see if I find it useful.  If others can test it
as well and give their feedback, even better.

Thanks!

James TD Smith ahktenz...@mohorovi.cc writes:

 These give the elapsed time since the TIMESTAMP and TIMESTAMP_IA
 properties. This value is in days, as a floating point number.

 For display in column view, this is converted to a human-readable time
 interval in the form 8d 02h 12m 22s.
 ---
  lisp/ChangeLog  |   18 --
  lisp/org-colview.el |   36 
  lisp/org.el |   23 ++-
  3 files changed, 58 insertions(+), 19 deletions(-)

 diff --git a/lisp/ChangeLog b/lisp/ChangeLog
 index 351731d..348ade3 100755
 --- a/lisp/ChangeLog
 +++ b/lisp/ChangeLog
 @@ -1,3 +1,17 @@
 +2009-07-12  James TD Smith  ahktenz...@mohorovi.cc
 +
 + * org-colview.el (org-format-time-period): Formats a time in
 + fractional days as days, hours, mins, seconds.
 + (org-columns-display-here): Add special handling for SINCE and
 + SINCE_IA to format for display.
 +
 + * org.el (org-time-since): Add a function to get the time since an
 + org timestamp.
 + (org-entry-properties): Add two new special properties: SINCE and
 + SINCE_IA. These give the time since any active or inactive
 + timestamp in an entry.
 + (org-special-properties): Add SINCE, SINCE_IA.
 +
  2009-07-08  Carsten Dominik  carsten.domi...@gmail.com
  
   * org-clock.el (org-clock-goto): Find hidden headlines as well.
 @@ -561,7 +575,7 @@
   `org-export-push-to-kill-ring'.
  
   * org-exp.el (org-export-show-temporary-export-buffer): New
 - option. 
 + option.
  
   * org-latex.el (org-export-as-latex): Use
   `org-export-show-temporary-export-buffer'.
 @@ -2861,7 +2875,7 @@
   (org-agenda-change-all-lines, org-tags-sparse-tree)
   (org-time-string-to-absolute, org-small-year-to-year)
   (org-link-escape): Re-apply changes accidentially overwritten
 - by last commit to Emacs.
 + by last commit to Emacs
  
  2008-11-23  Carsten Dominik  carsten.domi...@gmail.com
  
 diff --git a/lisp/org-colview.el b/lisp/org-colview.el
 index 7633b5b..6a89849 100644
 --- a/lisp/org-colview.el
 +++ b/lisp/org-colview.el
 @@ -190,18 +190,19 @@ This is the compiled version of the format.)
 (length property))
   f (format %%-%d.%ds |  width width)
   val (or (cdr ass) )
 - modval (or (and org-columns-modify-value-for-display-function
 - (functionp
 -  org-columns-modify-value-for-display-function)
 - (funcall
 -  org-columns-modify-value-for-display-function
 -  title val))
 -(if (equal property ITEM)
 -(if (org-mode-p)
 -(org-columns-cleanup-item
 - val org-columns-current-fmt-compiled)
 -  (org-agenda-columns-cleanup-item
 -   val pl cphr org-columns-current-fmt-compiled)
 + modval (cond ((and org-columns-modify-value-for-display-function
 +(functionp
 + org-columns-modify-value-for-display-function))
 +   (funcall org-columns-modify-value-for-display-function
 +title val))
 +((equal property ITEM)
 + (if (org-mode-p)
 + (org-columns-cleanup-item
 +  val org-columns-current-fmt-compiled)
 +   (org-agenda-columns-cleanup-item
 +val pl cphr org-columns-current-fmt-compiled)))
 +((or (equal property SINCE) (equal property 
 SINCE_IA))
 + (org-format-time-period val
(setq s2 (org-columns-add-ellipses (or modval val) width))
(setq string (format f s2))
;; Create the overlay
 @@ -1388,6 +1389,17 @@ This will add overlays to the date lines, to show the 
 summary for each day.
  (equal (nth 4 a) (nth 4 fm)))
 (org-columns-compute (car fm)))
  
 +(defun org-format-time-period (interval)
 +  (if (stringp interval)
 +  
 +(let* ((days (floor interval))
 +(frac-hours (* 24 (- interval days)))
 +(hours (floor frac-hours))
 +(minutes (floor (* 60 (- frac-hours hours
 +(seconds (floor (* 60 (- (* 60 (- frac-hours hours)) minutes)
 +  (format %dd %02dh %02dm %02ds days hours minutes seconds
 +
 +
  (provide 'org-colview)
  
  ;; arch-tag: 

Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-07-14 Thread James TD Smith
Hi Bastien,

On 2009-07-14 13:48:09(+0200), Bastien wrote:
 Hi James,

 welcome back.  Carsten is on vacation for three weeks and I'm
 maintaining Org in the meanwhile.

Thanks. I'd forgotten Carsten was away.

 I won't take the decision of adding new special properties without
 asking him so I don't apply this patch for now.  But I will use your
 patch for a while and see if I find it useful.  If others can test it
 as well and give their feedback, even better.

I use this mostly to check the age of entries when reviewing my todo lists;
either to cull old tasks I haven't started and aren't interested in any more, 
or to
remind me that I haven't worked on a task for a while and ought to do so.

I used to use the TIMESTAMP and TIMESTAMP_IA properties for this, and the new
properties work in more or less the same way but display the results
differently.

James

--
|-James TD Smith-email/ahktenz...@mohorovi.cc-|


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.

2009-07-13 Thread James TD Smith
These give the elapsed time since the TIMESTAMP and TIMESTAMP_IA
properties. This value is in days, as a floating point number.

For display in column view, this is converted to a human-readable time
interval in the form 8d 02h 12m 22s.
---
 lisp/ChangeLog  |   18 --
 lisp/org-colview.el |   36 
 lisp/org.el |   23 ++-
 3 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 351731d..348ade3 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
+2009-07-12  James TD Smith  ahktenz...@mohorovi.cc
+
+   * org-colview.el (org-format-time-period): Formats a time in
+   fractional days as days, hours, mins, seconds.
+   (org-columns-display-here): Add special handling for SINCE and
+   SINCE_IA to format for display.
+
+   * org.el (org-time-since): Add a function to get the time since an
+   org timestamp.
+   (org-entry-properties): Add two new special properties: SINCE and
+   SINCE_IA. These give the time since any active or inactive
+   timestamp in an entry.
+   (org-special-properties): Add SINCE, SINCE_IA.
+
 2009-07-08  Carsten Dominik  carsten.domi...@gmail.com
 
* org-clock.el (org-clock-goto): Find hidden headlines as well.
@@ -561,7 +575,7 @@
`org-export-push-to-kill-ring'.
 
* org-exp.el (org-export-show-temporary-export-buffer): New
-   option. 
+   option.
 
* org-latex.el (org-export-as-latex): Use
`org-export-show-temporary-export-buffer'.
@@ -2861,7 +2875,7 @@
(org-agenda-change-all-lines, org-tags-sparse-tree)
(org-time-string-to-absolute, org-small-year-to-year)
(org-link-escape): Re-apply changes accidentially overwritten
-   by last commit to Emacs.
+   by last commit to Emacs
 
 2008-11-23  Carsten Dominik  carsten.domi...@gmail.com
 
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 7633b5b..6a89849 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -190,18 +190,19 @@ This is the compiled version of the format.)
  (length property))
f (format %%-%d.%ds |  width width)
val (or (cdr ass) )
-   modval (or (and org-columns-modify-value-for-display-function
-   (functionp
-org-columns-modify-value-for-display-function)
-   (funcall
-org-columns-modify-value-for-display-function
-title val))
-  (if (equal property ITEM)
-  (if (org-mode-p)
-  (org-columns-cleanup-item
-   val org-columns-current-fmt-compiled)
-(org-agenda-columns-cleanup-item
- val pl cphr org-columns-current-fmt-compiled)
+   modval (cond ((and org-columns-modify-value-for-display-function
+  (functionp
+   org-columns-modify-value-for-display-function))
+ (funcall org-columns-modify-value-for-display-function
+  title val))
+  ((equal property ITEM)
+   (if (org-mode-p)
+   (org-columns-cleanup-item
+val org-columns-current-fmt-compiled)
+ (org-agenda-columns-cleanup-item
+  val pl cphr org-columns-current-fmt-compiled)))
+  ((or (equal property SINCE) (equal property 
SINCE_IA))
+   (org-format-time-period val
   (setq s2 (org-columns-add-ellipses (or modval val) width))
   (setq string (format f s2))
   ;; Create the overlay
@@ -1388,6 +1389,17 @@ This will add overlays to the date lines, to show the 
summary for each day.
   (equal (nth 4 a) (nth 4 fm)))
  (org-columns-compute (car fm)))
 
+(defun org-format-time-period (interval)
+  (if (stringp interval)
+  
+(let* ((days (floor interval))
+  (frac-hours (* 24 (- interval days)))
+  (hours (floor frac-hours))
+  (minutes (floor (* 60 (- frac-hours hours
+  (seconds (floor (* 60 (- (* 60 (- frac-hours hours)) minutes)
+  (format %dd %02dh %02dm %02ds days hours minutes seconds
+
+
 (provide 'org-colview)
 
 ;; arch-tag: 61f5128d-747c-4983-9479-e3871fa3d73c
diff --git a/lisp/org.el b/lisp/org.el
index feaa115..8843486 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6481,7 +6481,10 @@ WITH-CASE, the sorting considers case as well.
   (string-to-char (match-string 2))
 org-default-priority))
  ((= dcst ?r)
-  (or (org-entry-get nil property) ))
+  (or (org-entry-get nil