From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA. Date: Mon, 13 Jul 2009 09:27:58 +0100 Message-ID: <1247473682-23338-2-git-send-email-ahktenzero@mohorovi.cc> References: <1247473682-23338-1-git-send-email-ahktenzero@mohorovi.cc> Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQHaX-0002os-30 for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 05:12:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQHaR-0002mE-Ls for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 05:12:43 -0400 Received: from [199.232.76.173] (port=49005 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQHaR-0002m5-64 for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 05:12:39 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:62600 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MQHaQ-0008Sq-FP for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 05:12:39 -0400 In-Reply-To: <1247473682-23338-1-git-send-email-ahktenzero@mohorovi.cc> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 + + * 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 * 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 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, -- 1.6.3.3