From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Subject: Re: What is the best way to set #+DATE to today's date? Date: Thu, 6 Aug 2015 13:00:31 -0400 Message-ID: References: <87bnekmknk.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0111ba065d8abe051ca77744 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNOXZ-0000BI-IV for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 13:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNOXY-0002kI-7e for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 13:01:13 -0400 Received: from mail-ob0-x234.google.com ([2607:f8b0:4003:c01::234]:33812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNOXY-0002k5-19 for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 13:01:12 -0400 Received: by obbfr1 with SMTP id fr1so23730967obb.1 for ; Thu, 06 Aug 2015 10:01:11 -0700 (PDT) In-Reply-To: <87bnekmknk.fsf@gmx.us> 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: Rasmus Cc: emacs-org list --089e0111ba065d8abe051ca77744 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > Why don't you just use a timestamp? But that would need me to insert the timestamp manually each time before exports > You can update whenever you want or using > (org-insert-time-stamp (current-time)) > at the right spot. Wouldn't that too need manual navigation to #+date: and then eval that elisp form? -- Kaushal Modi On Thu, Aug 6, 2015 at 12:44 PM, Rasmus wrote: > Kaushal writes: > > > Hi all, > > > > There are quite few documents in which I want to update the date stamp = to > > the last update time. > > > > I like that #+DATE keyword value is used aptly in latex/pdf and html > > exports. > > > > But I couldn't find an elegant way for that date to be updated to today= 's > > (last updated) date. > > > > I came up with the below. But please let me know if there's an inbuilt > way > > to do the same. > > > > > > PART 1: Config in init.el > > > > ;; Update TODAY macro with current date > > (defun modi/org-update-TODAY-macro (&rest ignore) > > "Update TODAY macro to hold string with current date." > > (interactive) > > (when (derived-mode-p 'org-mode) > > (save-excursion > > (goto-char (point-min)) > > (while (re-search-forward > > "^\\s-*#\\+MACRO:\\s-+TODAY" > > nil 'noerror) > > (forward-line 0) > > (when (looking-at ".*TODAY\\(.*\\)") > > (replace-match > > (concat " " > > (format-time-string "%b %d %Y, %a" > (current-time))) > > :fixedcase :literal nil 1)))))) > > (add-hook 'org-export-before-processing-hook > > #'modi/org-update-TODAY-macro) > > > > > > PART 2: org document where I want the #+DATE to auto update > > > > #+MACRO: TODAY [current date is auto-inserted when exporting] > > #+DATE: {{{TODAY}}} > > Why don't you just use a timestamp? > > #+date: <2015-08-06> > > You can update whenever you want or using > > (org-insert-time-stamp (current-time)) > > at the right spot. > > Rasmus > > -- > S=C3=A5dan en god dansk lagereddike kan man slet ikke bruge mere > > > --089e0111ba065d8abe051ca77744 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> Why don't you just use a timestamp= ?

But that would nee= d me to insert the timestamp manually each time before exports

> You can update = whenever you want or using
> =C2=A0 =C2=A0(org-insert-time-stamp (curr= ent-time))
> at the right spot.

Wouldn't that too need manual navigation to #+= date: and then eval that elisp form?


--
Kaushal Modi

On Thu, Aug 6, 2015 at 12:44 PM, Rasmus <rasmus= @gmx.us> wrote:
Kaushal <kaushal.modi@gmail.com> writes:

> Hi all,
>
> There are quite few documents in which I want to update the date stamp= to
> the last update time.
>
> I like that #+DATE keyword value is used aptly in latex/pdf and html > exports.
>
> But I couldn't find an elegant way for that date to be updated to = today's
> (last updated) date.
>
> I came up with the below. But please let me know if there's an inb= uilt way
> to do the same.
>
>
> PART 1: Config in init.el
>
>=C2=A0 =C2=A0 =C2=A0;; Update TODAY macro with current date
>=C2=A0 =C2=A0 =C2=A0(defun modi/org-update-TODAY-macro (&rest ignor= e)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0"Update TODAY macro to hold string with= current date."
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(interactive)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (derived-mode-p 'org-mode)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(save-excursion
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (re-search-forward
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&q= uot;^\\s-*#\\+MACRO:\\s-+TODAY"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ni= l 'noerror)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-line 0)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (looking-at "= ;.*TODAY\\(.*\\)")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(replace-match >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat " = "
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (format-time-string "%b %d %Y, %a" (current-time)))=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :fixedcase :lit= eral nil 1))))))
>=C2=A0 =C2=A0 =C2=A0(add-hook 'org-export-before-processing-hook > #'modi/org-update-TODAY-macro)
>
>
> PART 2: org document where I want the #+DATE to auto update
>
>=C2=A0 =C2=A0 =C2=A0#+MACRO: TODAY [current date is auto-inserted when = exporting]
>=C2=A0 =C2=A0 =C2=A0#+DATE: {{{TODAY}}}

Why don't you just use a timestamp?

=C2=A0 =C2=A0 #+date: <2015-08-06>

You can update whenever you want or using

=C2=A0 =C2=A0 (org-insert-time-stamp (current-time))

at the right spot.

Rasmus

--
S=C3=A5dan en god dansk lagereddike kan man slet ikke bruge mere



--089e0111ba065d8abe051ca77744--