Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/06b1e3e968af99c33eea60d0a5a2e7b3 to your computer and use it in GitHub Desktop.
Save pandanote-info/06b1e3e968af99c33eea60d0a5a2e7b3 to your computer and use it in GitHub Desktop.
GitHub Pages用のmarkdownファイルに"update:"という行が現れたら、markdownファイルの保存時にそれらのうちの最初の行に最終更新日時を追加するためのEmacs Lispのプログラム。
;; 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