From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Subject: What is the best way to set #+DATE to today's date? Date: Thu, 6 Aug 2015 12:33:13 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01634c36bfa8c1051ca71536 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNO79-0001Qx-QG for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 12:33:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNO78-000447-Cu for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 12:33:55 -0400 Received: from mail-ob0-x22f.google.com ([2607:f8b0:4003:c01::22f]:36411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNO78-00043y-6M for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 12:33:54 -0400 Received: by obnw1 with SMTP id w1so59703432obn.3 for ; Thu, 06 Aug 2015 09:33:53 -0700 (PDT) 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: emacs-org list --089e01634c36bfa8c1051ca71536 Content-Type: text/plain; charset=UTF-8 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}}} -- Kaushal Modi --089e01634c36bfa8c1051ca71536 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all,

There are quite few documents in which I want to update the da= te stamp to the last update time.

I like that #+DATE keyword value is used aptly in latex/pdf and htm= l exports.

But I couldn'= t find an elegant way for that date to be updated to today's (last upda= ted) date.

I came up with th= e below. But please let me know if there's an inbuilt way to do the sam= e.


PART 1: Config in init.el

=C2=A0 =C2=A0 ;; Update TODAY macro w= ith current date
=C2=A0 =C2=A0 (defun modi/o= rg-update-TODAY-macro (&rest ignore)
=C2= =A0 =C2=A0 =C2=A0 "Update TODAY macro to hold string with current date= ."
=C2=A0 =C2=A0 =C2=A0 (interactive)
=C2=A0 =C2=A0 =C2=A0 (when (derived-mode-p &#= 39;org-mode)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (sa= ve-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (goto-char (point-min))
=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 "^\\= s-*#\\+MACRO:\\s-+TODAY"
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nil 'noerror)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (forward-l= ine 0)
=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 (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(f= ormat-time-string "%b %d %Y, %a" (current-time)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:fix= edcase :literal nil 1))))))
=C2=A0 =C2=A0 (a= dd-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 #+MACRO: TODAY [current date is auto-inserted = when exporting]
= =C2=A0 =C2=A0 #+DATE: {{{TODAY}}}

=

--
Kaushal Modi
--089e01634c36bfa8c1051ca71536--