From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Alexander_Wing=E5rd?= Subject: Re: Time range between now and timestamp Date: Thu, 15 Sep 2011 18:33:49 +0200 Message-ID: References: <064758C1-8D27-4647-A3C2-AB35FB8C6215@gmail.com> <5509.1316097429@alphaville.dokosmarshall.org> <6561.1316102575@alphaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4FBE-0000yx-Dp for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 12:52:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4FBD-0005Q4-8n for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 12:52:52 -0400 Received: from mail-wy0-f180.google.com ([74.125.82.180]:39892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4Eso-0001kl-Du for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 12:33:50 -0400 Received: by wyj26 with SMTP id 26so3944865wyj.39 for ; Thu, 15 Sep 2011 09:33:49 -0700 (PDT) In-Reply-To: <6561.1316102575@alphaville.dokosmarshall.org> 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: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org Wonderful, thanks alot! I can already see this becoming of great use to me. Best Regards /Alexander On Thu, Sep 15, 2011 at 6:02 PM, Nick Dokos wrote: > Alexander Wing=E5rd wrote: > >> Let's say I have this: >> >> <2011-09-15 Thu>--<2011-09-16 Fri> >> >> and I put my cursor over this and press C-c C-y my minibuffer will >> spit out 1 day. >> >> I would like a command that does the same thing if i execute it over >> just <2011-09-16 Fri>. >> >> Sometimes I'm interested in how much time there is left to a specific >> appointment. >> > > Here is one way to do it: > > --8<---------------cut here---------------start------------->8--- > (defun aw/org-evaluate-time-range (&optional to-buffer) > =A0(interactive) > =A0(if (org-at-date-range-p t) > =A0 =A0 =A0(org-evaluate-time-range to-buffer) > =A0 =A0;; otherwise, make a time range in a temp buffer and run o-e-t-r t= here > =A0 =A0(let ((headline (buffer-substring (point-at-bol) (point-at-eol)))) > =A0 =A0 =A0(with-temp-buffer > =A0 =A0 =A0 =A0(insert headline) > =A0 =A0 =A0 =A0(goto-char (point-at-bol)) > =A0 =A0 =A0 =A0(re-search-forward org-ts-regexp (point-at-eol) t) > =A0 =A0 =A0 =A0(if (not (org-at-timestamp-p t)) > =A0 =A0 =A0 =A0 =A0 =A0(error "No timestamp here")) > =A0 =A0 =A0 =A0(goto-char (match-beginning 0)) > =A0 =A0 =A0 =A0(org-insert-time-stamp (current-time) nil nil) > =A0 =A0 =A0 =A0(insert "--") > =A0 =A0 =A0 =A0(org-evaluate-time-range to-buffer))))) > --8<---------------cut here---------------end--------------->8--- > > There are probably better implementations; also, you might be able to adv= ise > o-e-t-r, instead of writing a new function, which would have the advantag= e > of preserving the key binding. > > AFAICT, the above works with dates in the past as well, but it always giv= es > the absolute value of the difference. > > Nick > >> >> On Thu, Sep 15, 2011 at 4:37 PM, Nick Dokos wrot= e: >> > Alexander Wing=E5rd wrote: >> > >> >> Hi! >> >> >> >> I really would want to have a command that given the cursor is over a >> >> timestamp would output the time-range from the current time to that >> >> timestamp. >> >> >> > >> > Can you please provide an example? I can interpret this >> > in a couple of different ways and I'm not sure what you >> > want. >> > >> > Also, when you say "output", do you mean that the function >> > should return e.g. a string representation of whatever it is >> > you want? Or print the result in the minibuffer? >> > Or insert it in the buffer you are editing? (and, if the last, >> > where?) >> > >> > Nick >> > >> >