emacs-orgmode
[Top][All Lists]
Advanced

[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: Rasmus
Subject: Re: [O] What is the best way to set #+DATE to today's date?
Date: Thu, 06 Aug 2015 18:44:31 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) 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}}}

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




reply via email to

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