From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: changing all timestamps in a document by a certain value? Date: Thu, 19 Jul 2012 10:36:19 -0400 Message-ID: References: <26428.1342669684@alphaville> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec53d5887f3222704c52fb3db Return-path: Received: from eggs.gnu.org ([208.118.235.92]:41402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srrq5-00045R-Pu for emacs-orgmode@gnu.org; Thu, 19 Jul 2012 10:36:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Srrq1-0000dI-9A for emacs-orgmode@gnu.org; Thu, 19 Jul 2012 10:36:25 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:51197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srrq0-0000d7-Vk for emacs-orgmode@gnu.org; Thu, 19 Jul 2012 10:36:21 -0400 Received: by weys10 with SMTP id s10so2226640wey.0 for ; Thu, 19 Jul 2012 07:36:20 -0700 (PDT) In-Reply-To: <26428.1342669684@alphaville> 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: Org Mode --bcaec53d5887f3222704c52fb3db Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jul 18, 2012 at 11:48 PM, Nick Dokos wrote: > Matt Price wrote: > > > I'm revising my course syllabi for next Fall and therefore need to > > update all the timestamps. In this case, I need to add 361 days to > > every stamp. Is there a function somewhere that can read a timestamp, > > convert it to a numerical value, change the value, and then record the > > new value in the right format? It would make my life easier if I could > > at least define a macro to do this. > > > > You might be able to do more precise surgery with org-element (just > guessing here: I haven't done anything with org-element yet), but if you > can search for the timestamps simply, you might be able to get away with > just a keyboard macro, e.g. if all timestamps are of the form > and *nothing else* looks like that, then a keyboard > macro that does something like the following: > > search for "<201" > advance a few chars to get to the DD part > ESC 361 S- > > might be all that you need. Then you repeat (once) with C-x e or (many > times) with C-u 1000 C-x e. > > But it really depends on identifying a search string that will not lead > you astray. Also make sure you save a backup of your file before you > start - you may have to do this a couple of times before you get it > right. > > Assuming that the simple search above is sufficient, doing > > C-x ( C-s < 2 0 1 RET 6*C-f ESC 3 6 1 C-x ) > > to define the macro should be enough. kmacro-edit-macro then shows me this: > > --8<---------------cut here---------------start------------->8--- > ;; Keyboard Macro Editor. Press C-c C-c to finish; press C-x k RET to > cancel. > ;; Original keys: C-s < 2 0 1 RET 6*C-f ESC 3 6 1 > > Command: last-kbd-macro > Key: none > > Macro: > > C-s ;; isearch-forward > < ;; self-insert-command > 2 ;; self-insert-command > 0 ;; self-insert-command > 1 ;; self-insert-command > RET ;; org-return > 6*C-f ;; forward-char > ESC > 3 ;; self-insert-command > 6 ;; self-insert-command > 1 ;; self-insert-command > ;; org-shiftup > --8<---------------cut here---------------end--------------->8--- > > HTH, > Nick > Thanks to both you guys -- I tried both solutions, they both work! I love this list. Matt --bcaec53d5887f3222704c52fb3db Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Wed, Jul 18, 2012 at 11:48 PM, Nick D= okos <nicholas.dokos@hp.com> wrote:
Matt Price <moptop99@gmail.com> wrote:

> I'm revising my course syllabi for next Fall and therefore need to=
> update all the timestamps.=A0 In this case, I need to add 361 days to<= br> > every stamp.=A0 Is there a function somewhere that can read a timestam= p,
> convert it to a numerical value, change the value, and then record the=
> new value in the right format? It would make my life easier if I could=
> at least define a macro to do this.=A0
>

You might be able to do more precise surgery with org-element (= just
guessing here: I haven't done anything with org-element yet), but if yo= u
can search for the timestamps simply, you might be able to get away with just a keyboard macro, e.g. if all timestamps are of the form
<YYYY-MM-DD ...> and *nothing else* looks like that, then a keyboard<= br> macro that does something like the following:

=A0 =A0 =A0search for "<201"
=A0 =A0 =A0advance a few chars to get to the DD part
=A0 =A0 =A0ESC 361 S-<up>

might be all that you need. Then you repeat (once) with C-x e or (many
times) with C-u 1000 C-x e.

But it really depends on identifying a search string that will not lead
you astray. =A0Also make sure you save a backup of your file before you
start - you may have to do this a couple of times before you get it
right.

Assuming that the simple search above is sufficient, doing

C-x ( C-s < 2 0 1 RET 6*C-f ESC 3 6 1 <S-up> C-x )

to define the macro should be enough. kmacro-edit-macro then shows me this:=

--8<---------------cut here---------------start------------->8---
;; Keyboard Macro Editor. =A0Press C-c C-c to finish; press C-x k RET to ca= ncel.
;; Original keys: C-s < 2 0 1 RET 6*C-f ESC 3 6 1 <S-up>

Command: last-kbd-macro
Key: none

Macro:

C-s =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; isearch-forward
< =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
2 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
RET =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; org-return
6*C-f =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; forward-char
ESC
3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
6 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command
<S-up> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; org-shiftup
--8<---------------cut here---------------end--------------->8---

HTH,
Nick

Thanks to both you guys -- I tried both solutions, t= hey both work!=A0 I love this list.

Matt

--bcaec53d5887f3222704c52fb3db--