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