Kaushal <kaushal.m...@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 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