* Re: Date macro - Org Mode
[not found] <CAGGEobVa24UE20k_Q1Bg5YTb8=T_aX6oYMQ6hBosAMYJ9rgicA@mail.gmail.com>
@ 2017-09-01 18:09 ` Matt Price
0 siblings, 0 replies; only message in thread
From: Matt Price @ 2017-09-01 18:09 UTC (permalink / raw)
To: Jay Iyer, Org Mode
[-- Attachment #1: Type: text/plain, Size: 2223 bytes --]
Hi Jay,
I'm sorry for the long delay in writing back -- I was travelling and let my
email get away from me. I'm doing something kind of similar but not exactly
the same. My problem is a little bit easier -- my dates aleays change by
exactly a week, so what I have done is to retain the first date and just
iteratively insert timestamps as i go. So I've written this defun:
(defun get-ts+7 ()
(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))))
))
Then I have an org file like:
#+MACRO: ts (eval (get-ts+7))
* Week {{{n}}} <2017-09-17 Tue>
* Week {{{n}}} {{{ts}}}
* Week {{{n}}} {{{ts}}}
* Week {{{n}}} {{{ts}}}
You could modify my defun to take a parameter, maybe something like this:
(defun get-ts+7 (plusdays)
(interactive)
(let ((base-date "<2017-09-17>")
(result nil))
(format-time-string "<%Y-%m-%d %a>"
(time-add
(date-to-time base-date) (days-to-time (1+
plusdays)))) ))
But then you'd need to eval the defun every time. So maybe something like
this:
#+MACRO: ts (eval (let ((base-date "<2017-09-17>")(result nil))
(format-time-string "<%Y-%m-%d %a>"(time-add (date-to-time base-date)
(days-to-time (1+ plusdays)))) ))
You'd have to customize the base-date value every time but maybe the above
would work otherwise. I think macro definitions have to be one-liners,
butm aybe not...
On Sun, Aug 27, 2017 at 12:32 PM, Jay Iyer <jayiyer09@gmail.com> wrote:
> Hi Matt,
> I was wondering what is your usage of the date macro question you posted
> here: http://lists.gnu.org/archive/html/emacs-orgmode/
> 2017-08/msg00605.html
>
> What I am trying to do is set a base date in a document and then use a
> macro to define incremental dates such as "base date + n days" as the
> document develops and I am wondering whether your macro would help me with
> this.
>
> Please let me know your thoughts.
>
> Thanks, Matt.
> -jay
>
>
>
[-- Attachment #2: Type: text/html, Size: 4070 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-01 18:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAGGEobVa24UE20k_Q1Bg5YTb8=T_aX6oYMQ6hBosAMYJ9rgicA@mail.gmail.com>
2017-09-01 18:09 ` Date macro - Org Mode Matt Price
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.