From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Time range between now and timestamp Date: Thu, 15 Sep 2011 12:02:55 -0400 Message-ID: <6561.1316102575@alphaville.dokosmarshall.org> References: <064758C1-8D27-4647-A3C2-AB35FB8C6215@gmail.com> <5509.1316097429@alphaville.dokosmarshall.org> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:40319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4EP0-00021x-WC for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 12:03:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4EOw-0002Dr-VK for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 12:03:02 -0400 Received: from g1t0028.austin.hp.com ([15.216.28.35]:3280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4EOw-0002DZ-LQ for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 12:02:58 -0400 In-Reply-To: Message from =?us-ascii?Q?=3D=3FISO-8859-1=3FQ=3FAlexander=5F?= =?us-ascii?Q?Wing=3DE5rd=3F=3D?= of "Thu\, 15 Sep 2011 16\:46\:20 +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: =?us-ascii?Q?=3D=3FISO-8859-1=3FQ=3FAlexander=5FWing=3DE5rd=3F=3D?= Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Alexander Wing=C3=A5rd wrote: > Let's say I have this: >=20 > <2011-09-15 Thu>--<2011-09-16 Fri> >=20 > and I put my cursor over this and press C-c C-y my minibuffer will > spit out 1 day. >=20 > I would like a command that does the same thing if i execute it over > just <2011-09-16 Fri>. >=20 > Sometimes I'm interested in how much time there is left to a specific > appointment. >=20 Here is one way to do it: --8<---------------cut here---------------start------------->8--- (defun aw/org-evaluate-time-range (&optional to-buffer) (interactive) (if (org-at-date-range-p t) (org-evaluate-time-range to-buffer) ;; otherwise, make a time range in a temp buffer and run o-e-t-r there (let ((headline (buffer-substring (point-at-bol) (point-at-eol)))) (with-temp-buffer (insert headline) (goto-char (point-at-bol)) (re-search-forward org-ts-regexp (point-at-eol) t) (if (not (org-at-timestamp-p t)) (error "No timestamp here")) (goto-char (match-beginning 0)) (org-insert-time-stamp (current-time) nil nil) (insert "--") (org-evaluate-time-range to-buffer))))) --8<---------------cut here---------------end--------------->8--- There are probably better implementations; also, you might be able to advise o-e-t-r, instead of writing a new function, which would have the advantage of preserving the key binding. AFAICT, the above works with dates in the past as well, but it always gives the absolute value of the difference. Nick >=20 > On Thu, Sep 15, 2011 at 4:37 PM, Nick Dokos wrote: > > Alexander Wing=C3=A5rd 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 > > >=20