* Time range between now and timestamp @ 2011-09-14 22:38 Alexander Wingård 2011-09-15 14:37 ` Nick Dokos 0 siblings, 1 reply; 5+ messages in thread From: Alexander Wingård @ 2011-09-14 22:38 UTC (permalink / raw) To: emacs-orgmode 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. I've been searching a lot for this but no luck and I even did an attempt to implement some hacked version of org-evaluate-time-range and org-days-to-time but since my experience with lisp is absolutely zero I failed miserably. I imagine someone here could help me whip this up in a couple of lines or maybe such feature can already be achieved? Best Regards /Alexander Ps. I love org-mode ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Time range between now and timestamp 2011-09-14 22:38 Time range between now and timestamp Alexander Wingård @ 2011-09-15 14:37 ` Nick Dokos 2011-09-15 14:46 ` Alexander Wingård 0 siblings, 1 reply; 5+ messages in thread From: Nick Dokos @ 2011-09-15 14:37 UTC (permalink / raw) To: =?iso-8859-1?Q?Alexander_Wing=E5rd?=; +Cc: nicholas.dokos, emacs-orgmode Alexander Wingård <alexander.wingard@gmail.com> 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Time range between now and timestamp 2011-09-15 14:37 ` Nick Dokos @ 2011-09-15 14:46 ` Alexander Wingård 2011-09-15 16:02 ` Nick Dokos 0 siblings, 1 reply; 5+ messages in thread From: Alexander Wingård @ 2011-09-15 14:46 UTC (permalink / raw) To: nicholas.dokos; +Cc: emacs-orgmode 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. Best Regards /Alexander On Thu, Sep 15, 2011 at 4:37 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: > Alexander Wingård <alexander.wingard@gmail.com> 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 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Time range between now and timestamp 2011-09-15 14:46 ` Alexander Wingård @ 2011-09-15 16:02 ` Nick Dokos 2011-09-15 16:33 ` Alexander Wingård 0 siblings, 1 reply; 5+ messages in thread From: Nick Dokos @ 2011-09-15 16:02 UTC (permalink / raw) To: =?ISO-8859-1?Q?Alexander_Wing=E5rd?=; +Cc: nicholas.dokos, emacs-orgmode Alexander Wingård <alexander.wingard@gmail.com> 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) (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 > > On Thu, Sep 15, 2011 at 4:37 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: > > Alexander Wingård <alexander.wingard@gmail.com> 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 > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Time range between now and timestamp 2011-09-15 16:02 ` Nick Dokos @ 2011-09-15 16:33 ` Alexander Wingård 0 siblings, 0 replies; 5+ messages in thread From: Alexander Wingård @ 2011-09-15 16:33 UTC (permalink / raw) To: nicholas.dokos; +Cc: emacs-orgmode 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 <nicholas.dokos@hp.com> wrote: > Alexander Wingård <alexander.wingard@gmail.com> 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) > (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 > >> >> On Thu, Sep 15, 2011 at 4:37 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: >> > Alexander Wingård <alexander.wingard@gmail.com> 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 >> > >> > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-15 16:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-09-14 22:38 Time range between now and timestamp Alexander Wingård 2011-09-15 14:37 ` Nick Dokos 2011-09-15 14:46 ` Alexander Wingård 2011-09-15 16:02 ` Nick Dokos 2011-09-15 16:33 ` Alexander Wingård
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).