[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] What is the best way to set #+DATE to today's date?

From: Nick Dokos
Subject: Re: [O] What is the best way to set #+DATE to today's date?
Date: Thu, 06 Aug 2015 14:12:07 -0400
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Kaushal <address@hidden> 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)}}}


        (info "(org) Macro replacement")

reply via email to

[Prev in Thread] Current Thread [Next in Thread]