org fileの更新日時をアップデートする
orgファイルの更新情報を追記できるようにしたかった。
基本的にはここに書いてあるものをコピペだが、一部kill-ringのところなどを変更して利用
(defun my/update-org-modified-property () "If a file contains a '#+LAST_MODIFIED' property update it to contain the current date/time" (interactive) (save-excursion (widen) (goto-char (point-min)) (when (re-search-forward "^#\\+LAST_MODIFIED:" (point-max) t) (progn ;; https://www.emacswiki.org/emacs/ElispCookbook#h5o-13 (let ((beg (point))) (forward-line 1) (forward-char -1) (delete-region beg (point))) ;; (kill-line) (insert (format-time-string " [%Y-%m-%d %a %H:%M]") ))))) (defun my/org-mode-before-save-hook () (when (eq major-mode 'org-mode) (my/update-org-modified-property))) (add-hook 'before-save-hook #'my/org-mode-before-save-hook)