Skip to content

Instantly share code, notes, and snippets.

@Khoulaiz
Created September 7, 2022 14:03
Show Gist options
  • Save Khoulaiz/84f44aae7623113a98ed0489b5c7b80d to your computer and use it in GitHub Desktop.
Save Khoulaiz/84f44aae7623113a98ed0489b5c7b80d to your computer and use it in GitHub Desktop.
Emacs Org-Mode: Inserts a timestamp into an exported org-file for the time of the export. Original org-file is untouched.
;; in your init.el
(defun ace/org-export-insert-export-date(&optional backend)
"Searches for %%DATE_EXPORTED%% in the buffer and replaces all occurrences
Just put the keyword somewhere in your org buffer and the time stamp of the
export is inserted in the exported buffer. The original buffer is untouched."
(goto-char (point-min))
(while (search-forward "%%DATE_EXPORTED%%" nil t)
(replace-match (format-time-string "%0e.%0m.%Y %R"))))
;; after org-mode was loaded
(add-hook 'org-export-before-parsing-hook 'ace/org-export-insert-export-date)
;; rest of your init.el
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment