From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: What is the best way to set #+DATE to today's date? Date: Thu, 06 Aug 2015 14:12:07 -0400 Message-ID: <87r3ngthfs.fsf@pierrot.dokosmarshall.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNPeQ-0004Zb-4U for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 14:12:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNPeK-0008DX-Ud for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 14:12:22 -0400 Received: from plane.gmane.org ([80.91.229.3]:47263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNPeK-0008BH-Ni for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 14:12:16 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZNPeI-0006Gq-Ok for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 20:12:14 +0200 Received: from pool-108-20-41-232.bstnma.fios.verizon.net ([108.20.41.232]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Aug 2015 20:12:14 +0200 Received: from ndokos by pool-108-20-41-232.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Aug 2015 20:12:14 +0200 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-orgmode@gnu.org 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}}} > There is a built-in-macro - try e.g. #+DATE: {{{time(%Y-%m-%d)}}} See (info "(org) Macro replacement") -- Nick