[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] How can I calculate the "age" of a headline?
From: |
Samuel Wales |
Subject: |
Re: [O] How can I calculate the "age" of a headline? |
Date: |
Tue, 19 Aug 2014 14:30:33 -0700 |
i call these time spans.
to me, it would be excellent as a custom timestamp format.
this requires a patch to org at this location:
Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index b1dc1ce..4497693 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16814,6 +16814,8 @@ The command returns the inserted time stamp."
tf (funcall (if with-hm 'cdr 'car) org-time-stamp-custom-formats)
time (org-fix-decoded-time t1)
str (org-add-props
+ ;; fixme alpha make it so that you can run a function
+ ;; (alpha-org-annotate-ts-with-time-span
(format-time-string
(substring tf 1 -1) (apply 'encode-time time))
nil 'mouse-face 'highlight)
then the code for the time spans is as follows.
(defun alpha-org-time-span-as-string (&optional from now)
"Return the time span from now
to the active or inactive Org timestamp at point, or nil.
+1 means tomorrow.
0 means today.
-1 means yesterday.
from and now are daynums.
"
;; (alpha-org-time-span from now)
(let ((from (or from (alpha-org-daynum-from-ts-at-point)))
(now (or now (alpha-org-daynum-from-now))))
(when (and from now)
(alpha-org-format-time-span (- from now)))))
(defun alpha-org-format-time-span (span)
;; + makes the numbers line up better
;; fixme emacs bug with 0
(format " = %+-3g" span))
;; (format " [= %+-3g]" span))
(defun alpha-org-daynum-from-ts (ts)
(time-to-days (org-time-string-to-time ts)))
;; (alpha-org-daynum-from-now)
(defun alpha-org-daynum-from-now ()
(alpha-org-daynum-from-ts "<now>"))
(defun alpha-org-daynum-from-ts-at-point ()
;; inactive too
;; (if ts
;; (alpha-org-daynum-from-ts ts)
(when (org-at-timestamp-p t)
(alpha-org-daynum-from-ts
(substring (match-string 1) 0 10))))
On 8/19/14, M <address@hidden> wrote:
> In my task lists, I'm working with scheduled and deadline dates.
> However, it would also often be very interesting, how "old" a task is, how
> long it is lurking around on my lists..
>
> Therefore it would be interesting to find the oldest timestamp below this
> heading and calculate the difference in days to today.
>
> Is that possible with org-mode already?
> Could I display this information in a tabular agenda view in a column?
>
> Kind regards
>
> Martin
>
>
>
>
--
The Kafka Pandemic: http://thekafkapandemic.blogspot.com
The disease DOES progress. MANY people have died from it. And
ANYBODY can get it.
Denmark: free Karina Hansen NOW.