emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* What is the best way to set #+DATE to today's date?
@ 2015-08-06 16:33 Kaushal
  2015-08-06 16:44 ` Rasmus
  2015-08-06 18:12 ` Nick Dokos
  0 siblings, 2 replies; 22+ messages in thread
From: Kaushal @ 2015-08-06 16:33 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

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}}}


--
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 5138 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-08-11 22:57 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 16:33 What is the best way to set #+DATE to today's date? Kaushal
2015-08-06 16:44 ` Rasmus
2015-08-06 17:00   ` Kaushal
2015-08-06 17:41     ` Rasmus
2015-08-06 18:18     ` John Kitchin
2015-08-06 19:25       ` Kaushal
2015-08-06 19:45         ` Kaushal
2015-08-06 19:50           ` Thomas S. Dye
2015-08-06 19:58             ` Kaushal
2015-08-06 20:51               ` [PATCH] " Thomas S. Dye
2015-08-06 21:22                 ` Kaushal
2015-08-06 21:48                   ` Thomas S. Dye
2015-08-06 21:54                     ` Fabrice Niessen
2015-08-06 22:12                       ` Thomas S. Dye
2015-08-07  8:53                         ` Nicolas Goaziou
2015-08-07 14:01                           ` Kaushal
2015-08-07 14:20                             ` Suvayu Ali
2015-08-07 14:52                               ` Kaushal
2015-08-11 18:40                           ` Thomas S. Dye
2015-08-11 22:59                             ` Nicolas Goaziou
2015-08-07  4:31     ` Suvayu Ali
2015-08-06 18:12 ` Nick Dokos

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).