From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: What is the best way to set #+DATE to today's date? Date: Thu, 06 Aug 2015 18:44:31 +0200 Message-ID: <87bnekmknk.fsf@gmx.us> 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]:38261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNOHe-0005Ak-58 for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 12:44:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNOHY-0000jC-AE for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 12:44:45 -0400 Received: from plane.gmane.org ([80.91.229.3]:42315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNOHY-0000j6-3L for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 12:44:40 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZNOHW-0002RL-4i for emacs-orgmode@gnu.org; Thu, 06 Aug 2015 18:44:38 +0200 Received: from ip5b4025d5.dynamic.kabel-deutschland.de ([91.64.37.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Aug 2015 18:44:38 +0200 Received: from rasmus by ip5b4025d5.dynamic.kabel-deutschland.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Aug 2015 18:44:38 +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}}} 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ådan en god dansk lagereddike kan man slet ikke bruge mere