mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
39 lines
1.7 KiB
Org Mode
39 lines
1.7 KiB
Org Mode
#+title: Use timestamps for effectively future-proofing your stuff
|
|
#+date: "2020-09-16 23:09:01 +08:00"
|
|
#+date_modified: "2021-05-02 02:15:26 +08:00"
|
|
#+language: en
|
|
|
|
|
|
One of the simplest ways to future-proof your documents with [[file:2020-04-13-17-32-27.org][File metadata]] is to create a timestamp.
|
|
Specifically, two timestamps: one when it's created and one when it was last modified which will be continuously updated each time we modify the file.
|
|
This lets you quickly evaluate whether the information is up-to-date without relying on the filesystem.
|
|
It also lets you [[file:2020-04-14-18-28-55.org][Maintain your own digital library]] with relative ease if your focus is on up-to-date information.
|
|
|
|
In order to make updating the modification timestamp not tedious, it is best to automate that task.
|
|
Different files may be applied differently as long as we can create a unified interface to search through them all.
|
|
|
|
Here's an example with Org mode documents:
|
|
|
|
#+begin_src org :exports none
|
|
\#+DATE: "2020-09-16 23:53:00 +08:00"
|
|
\#+DATE_MODIFIED: "2020-09-17 10:33:42 +08:00"
|
|
#+end_src
|
|
|
|
Emacs has a built-in time stamp feature that already took care of that task.
|
|
We can then attach the timestamp update with a hook that will occur before saving the file and voila!
|
|
Automated timestamp for our text documents. :D
|
|
|
|
Here's my (Doom Emacs) specific config as of 2020-09-17 for future references:
|
|
|
|
#+begin_src elisp
|
|
(after org!
|
|
(setq
|
|
; Set a custom time-stamp pattern.
|
|
; Even though, it's not recommended, most of the time,
|
|
time-stamp-start "DATE_MODIFIED:[ ]+\\\\?[\"<]+"))
|
|
|
|
; Modify the time-stamp with each save.
|
|
(setq time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S%:z")
|
|
(add-hook 'before-save-hook 'time-stamp)
|
|
#+end_src
|