From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA. Date: Tue, 14 Jul 2009 13:48:09 +0200 Message-ID: <87prc3v52y.fsf@bzg.ath.cx> References: <1247473682-23338-1-git-send-email-ahktenzero@mohorovi.cc> <1247473682-23338-2-git-send-email-ahktenzero@mohorovi.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQbDJ-0008R7-57 for emacs-orgmode@gnu.org; Tue, 14 Jul 2009 02:10:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQbDE-0008Qk-5p for emacs-orgmode@gnu.org; Tue, 14 Jul 2009 02:10:04 -0400 Received: from [199.232.76.173] (port=38386 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQbDD-0008Qf-Qy for emacs-orgmode@gnu.org; Tue, 14 Jul 2009 02:09:59 -0400 Received: from rv-out-0708.google.com ([209.85.198.242]:48941) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQbDC-00082u-QS for emacs-orgmode@gnu.org; Tue, 14 Jul 2009 02:09:59 -0400 Received: by rv-out-0708.google.com with SMTP id c5so773588rvf.2 for ; Mon, 13 Jul 2009 23:09:57 -0700 (PDT) In-Reply-To: <1247473682-23338-2-git-send-email-ahktenzero@mohorovi.cc> (James TD Smith's message of "Mon, 13 Jul 2009 09:27:58 +0100") 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: James TD Smith Cc: emacs-orgmode@gnu.org 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 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 > + > + * 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, -- Bastien