Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
GitHub Pages用のmarkdownファイルに"update:"という行が現れたら、markdownファイルの保存時にそれらのうちの最初の行に最終更新日時を追加するためのEmacs Lispのプログラム。
;; See for details.
(defun insert-timestamp-for-githubpages ()
"Insert time stamp into the line starting from \"update: \"."
(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)
(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