From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: Time shifting functions Date: Fri, 27 Apr 2018 11:53:04 -0400 Message-ID: References: <9d598ff5-8596-5928-b81b-e312b6722d54@yandex.ru> <878t99sfsf.fsf@bzg.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ec0713056ad67fb8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fC5gL-0004zU-Ve for emacs-orgmode@gnu.org; Fri, 27 Apr 2018 11:53:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fC5gK-0000oi-TF for emacs-orgmode@gnu.org; Fri, 27 Apr 2018 11:53:09 -0400 In-Reply-To: <878t99sfsf.fsf@bzg.fr> 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" To: Bastien Cc: Andrei Beliankou , Org Mode --000000000000ec0713056ad67fb8 Content-Type: text/plain; charset="UTF-8" On Thu, Apr 26, 2018 at 7:34 PM, Bastien wrote: > Hi Andrei, > > Andrei Beliankou writes: > > > I wonder if Org-mode has a convinient function to shift a timestamp with > > a (weekly) repeating interval by that interval. > > Actually the same way `org-read-date' reads the time in the timestamp > it could also read a repeater interval, so that C-c C-s would present > you with this repeater interval by default. > > Would that make sense for you? > > Huh, that sounds interesting. What I did was define this function: ;; this is the one I'm currently using (defun get-ts+7 () "returns a string of the form <%Y-%m-d %a> where the date elements are 7 days later than the previous timestamp in the buffer. No error checking or anything yet." (interactive) (let ((base-date (save-excursion (re-search-backward (org-re-timestamp 'all)) (match-string 0))) (result nil)) (format-time-string "<%Y-%m-%d %a>" (time-add (date-to-time base-date) (days-to-time (1+ 7)))) )) And then I use this macro: #+MACRO: ts (eval (get-ts+7)) And then my headings look like this: * Week {{{n}}} (<2017-09-11 Mon>):Intro. On Discussion. * Week {{{n}}} ({{{ts}}}): What is a River? * Week {{{n}}} ({{{ts}}}): Rivers in the Broad Sweep of Time It's not easy to look at in its org-native form, but it's pretty good on export. --000000000000ec0713056ad67fb8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, Apr 26, 2018 at 7:34 PM, Bastien <bzg@gnu.org> wrote:=
Hi Andrei,

Andrei Beliankou <arbox@yandex.ru= > writes:

> I wonder if Org-mode has a convinient function to shift a timestamp wi= th
> a (weekly) repeating interval by that interval.

Actually the same way `org-read-date' reads the time in the time= stamp
it could also read a repeater interval, so that C-c C-s would present
you with this repeater interval by default.

Would that make sense for you?


Huh, that sounds interesting. What I did was d= efine this function:

;; this is the one I'= ;m currently using
(defun get-ts+7 ()
"returns a string of the f= orm <%Y-%m-d %a> where the date elements are 7 days later
than the= previous timestamp in the buffer. No error checking or anything yet."=
=C2=A0=C2=A0=C2=A0 (interactive)
=C2=A0=C2=A0=C2=A0 (let ((base-date= (save-excursion
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (re-search-backward
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (org-re-timestamp 'all))
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (m= atch-string 0)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = (result nil))
=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (for= mat-time-string "<%Y-%m-%d %a>"
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (time-add
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (d= ate-to-time base-date) (days-to-time (1+ 7)))) ))
=C2=A0
= And then I use this macro:

#+MACRO: ts (eval = (get-ts+7))

And then my headings look like this:

* Week {{{n}}} (<2017-09-11 Mon>):Intro. On D= iscussion.
* Week {{{n}}} ({{{ts}}}): What is a River?
* Week {{{n}= }} ({{{ts}}}): Rivers in the Broad Sweep of Time

I= t's not easy to look at in its org-native form, but it's pretty goo= d on export.
--000000000000ec0713056ad67fb8--