emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* changing all timestamps in a document by a certain value?
@ 2012-07-19  1:46 Matt Price
  2012-07-19  3:48 ` Nick Dokos
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Price @ 2012-07-19  1:46 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Hi,

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.

Thanks guys!
Matt

[-- Attachment #2: Type: text/html, Size: 440 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: changing all timestamps in a document by a certain value?
  2012-07-19  1:46 changing all timestamps in a document by a certain value? Matt Price
@ 2012-07-19  3:48 ` Nick Dokos
  2012-07-19 14:36   ` Matt Price
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Dokos @ 2012-07-19  3:48 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Matt Price <moptop99@gmail.com> 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
<YYYY-MM-DD ...> 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-<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.  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 <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.  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 <S-up>

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
<S-up>			;; org-shiftup
--8<---------------cut here---------------end--------------->8---

HTH,
Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: changing all timestamps in a document by a certain value?
  2012-07-19  3:48 ` Nick Dokos
@ 2012-07-19 14:36   ` Matt Price
  0 siblings, 0 replies; 3+ messages in thread
From: Matt Price @ 2012-07-19 14:36 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 2526 bytes --]

On Wed, Jul 18, 2012 at 11:48 PM, Nick Dokos <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.  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
> <YYYY-MM-DD ...> 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-<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.  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 <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.  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 <S-up>
>
> 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
> <S-up>                  ;; 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

[-- Attachment #2: Type: text/html, Size: 3167 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-19 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-19  1:46 changing all timestamps in a document by a certain value? Matt Price
2012-07-19  3:48 ` Nick Dokos
2012-07-19 14:36   ` Matt Price

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).