From: Matt Price <moptop99@gmail.com>
To: Jay Iyer <jayiyer09@gmail.com>, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Date macro - Org Mode
Date: Fri, 1 Sep 2017 14:09:11 -0400 [thread overview]
Message-ID: <CAN_Dec90_RYiOPK2nJtPD7K6WhAoLkcu2TuctcivvpDg4LDZOQ@mail.gmail.com> (raw)
In-Reply-To: <CAGGEobVa24UE20k_Q1Bg5YTb8=T_aX6oYMQ6hBosAMYJ9rgicA@mail.gmail.com>
[-- 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 --]
parent reply other threads:[~2017-09-01 18:09 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAGGEobVa24UE20k_Q1Bg5YTb8=T_aX6oYMQ6hBosAMYJ9rgicA@mail.gmail.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN_Dec90_RYiOPK2nJtPD7K6WhAoLkcu2TuctcivvpDg4LDZOQ@mail.gmail.com \
--to=moptop99@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jayiyer09@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).