Created
November 8, 2020 09:18
-
-
Save pandanote-info/06b1e3e968af99c33eea60d0a5a2e7b3 to your computer and use it in GitHub Desktop.
GitHub Pages用のmarkdownファイルに"update:"という行が現れたら、markdownファイルの保存時にそれらのうちの最初の行に最終更新日時を追加するためのEmacs Lispのプログラム。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; See https://pandanote.info/?p=6871 for details. | |
(defun insert-timestamp-for-githubpages () | |
"Insert time stamp into the line starting from \"update: \"." | |
(interactive) | |
(goto-char 0) | |
(if (re-search-forward "^update:.*$" nil t) | |
(replace-match (concat "update: " (current-time-string) " " (format-time-string "%z")))) | |
) | |
(defun insert-timestamp-for-githubpages-for-markdown () | |
"Check the major mode to invoke insert-timestamp-for-githubpages." | |
(when (eq major-mode 'markdown-mode) | |
(insert-timestamp-for-githubpages)) | |
) | |
(add-hook 'before-save-hook #'insert-timestamp-for-githubpages-for-markdown) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment