emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SI


From: Bastien
Subject: Re: [Orgmode] [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.
Date: Tue, 14 Jul 2009 13:48:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

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 <address@hidden> 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  <address@hidden>
> +
> +     * 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  <address@hidden>
>  
>       * 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  <address@hidden>
>  
> 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 property)
> +                (if (or (equal property "SINCE") (equal property "SINCE_IA"))
> +                    0
> +                  "")))
>             ((= dcst ?o)
>              (if (looking-at org-complex-heading-regexp)
>                  (- 9999 (length (member (match-string 2)
> @@ -11286,10 +11289,9 @@ a *different* entry, you cannot use these 
> techniques."
>  ;;;; Properties
>  
>  ;;; Setting and retrieving properties
> -
>  (defconst org-special-properties
>    '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "CLOSED" 
> "PRIORITY"
> -    "TIMESTAMP" "TIMESTAMP_IA")
> +    "TIMESTAMP" "TIMESTAMP_IA" "SINCE" "SINCE_IA")
>    "The special properties valid in Org-mode.
>  
>  These are properties that are not defined in the property drawer,
> @@ -11433,8 +11435,13 @@ If WHICH is nil or `all', get all properties.  If 
> WHICH is
>                 (setq key "TIMESTAMP")))
>             (when (or (equal key clockstr) (not (assoc key props)))
>               (push (cons key string) props)))
> -
> -         )
> +         (when (assoc "TIMESTAMP_IA" props)
> +           (push (cons "SINCE_IA"
> +                       (org-time-since (cdr (assoc "TIMESTAMP_IA" props))))
> +                 props))
> +         (when (assoc "TIMESTAMP" props)
> +           (push (cons "SINCE" (org-time-since (cdr (assoc "TIMESTAMP" 
> props))))
> +                 props)))
>  
>         (when (memq which '(all standard))
>           ;; Get the standard properties, like :PROP: ...
> @@ -11460,6 +11467,12 @@ If WHICH is nil or `all', get all properties.  If 
> WHICH is
>           (push (cons "CATEGORY" value) props))
>         (append sum-props (nreverse props)))))))
>  
> +(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 org-entry-get (pom property &optional inherit)
>    "Get value of PROPERTY for entry at point-or-marker POM.
>  If INHERIT is non-nil and the entry does not have the property,

-- 
 Bastien




reply via email to

[Prev in Thread] Current Thread [Next in Thread]