From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: How can I calculate the "age" of a headline? Date: Tue, 19 Aug 2014 19:50:00 +0200 Message-ID: <87oavge5dj.fsf@gmail.com> References: <87tx58ebni.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJnY8-0000ss-1r for emacs-orgmode@gnu.org; Tue, 19 Aug 2014 13:50:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJnY2-000827-45 for emacs-orgmode@gnu.org; Tue, 19 Aug 2014 13:50:23 -0400 Received: from plane.gmane.org ([80.91.229.3]:39928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJnY1-00081q-Td for emacs-orgmode@gnu.org; Tue, 19 Aug 2014 13:50:18 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XJnXw-0004wE-P8 for emacs-orgmode@gnu.org; Tue, 19 Aug 2014 19:50:12 +0200 Received: from g231224050.adsl.alicedsl.de ([92.231.224.50]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Aug 2014 19:50:12 +0200 Received: from tjolitz by g231224050.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Aug 2014 19:50:12 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org M writes: > Thanks! > I'm using a setup based on Bert Hansen's, so I think I'm already using this > feature and a new headline looks like that: > > ** new headline > [2014-08-19 Di 18:28] > > however, my question is how I can search for this timestamp (I'm not > sure if > it is always at the same line below the headline, as sometimes there is a > logbook inbetween) and calculate the difference to today in days and then > display that as a separate column M writes: > Thanks! > I'm using a setup based on Bert Hansen's, so I think I'm already using this > feature and a new headline looks like that: > > ** new headline > [2014-08-19 Di 18:28] > > however, my question is how I can search for this timestamp (I'm not > sure if > it is always at the same line below the headline, as sometimes there is a > logbook inbetween) and calculate the difference to today in days and then > display that as a separate column I don't know about that column stuff, but a variation of John's solution should give you the info you want: #+BEGIN_SRC emacs-lisp (defun my-time-to-now () (interactive) (save-restriction (org-narrow-to-subtree) (org-time-stamp-to-now (org-element-map (org-element-parse-buffer) 'timestamp (lambda (--stamp) (when (eq (org-element-property :type --stamp) 'inactive) (org-element-property :raw-value --stamp))) nil 'FIRST-MATCH)))) #+END_SRC #+results: : my-time-to-now #+BEGIN_SRC emacs-lisp :results pp (save-excursion (outline-next-heading) (my-time-to-now)) #+END_SRC #+results: : -2 * ORG SCRATCH <2014-08-19 Di> [2014-08-17 So 19:30] > Kind regards > > Martin > > >> Von: Thorsten Jolitz >> Datum: Tue, 19 Aug 2014 17:34:25 +0200 >> An: >> Betreff: Re: [O] How can I calculate the "age" of a headline? >> >> M writes: >> >>> 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.. >> >> I copied Bernt Hansens setup for toggling automatic insertion of >> inactive timestamps at headline creation. The tj/ prefix is there only >> for my convenience, it should really be bh/ (-> Bernt Hansen). >> >> #+BEGIN_SRC emacs-lisp >> ;; *** Timestamps >> >> ;; **** Configuration >> >> (add-hook 'org-insert-heading-hook >> 'tj/insert-heading-inactive-timestamp 'append) >> >> ;; **** Functions >> >> (defvar tj/insert-inactive-timestamp t) >> >> (defun tj/toggle-insert-inactive-timestamp () >> (interactive) >> (setq tj/insert-inactive-timestamp >> (not tj/insert-inactive-timestamp)) >> (message "Heading timestamps are %s" >> (if tj/insert-inactive-timestamp "ON" "OFF"))) >> >> (defun tj/insert-inactive-timestamp () >> (interactive) >> (org-insert-time-stamp nil t t nil nil nil)) >> >> (defun tj/insert-heading-inactive-timestamp () >> (save-excursion >> (when tj/insert-inactive-timestamp >> (org-return) >> (org-cycle) >> (tj/insert-inactive-timestamp)))) >> #+END_SRC >> >> -- >> cheers, >> Thorsten >> >> > > > > -- cheers, Thorsten