0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Markdown形式のHugo Front Matterの日時をemacsで自動的に更新する

Last updated at Posted at 2024-07-23

概要

asciidoctor形式での自動更新の記事の設定をMarkdownにしたほか、2点変更しています。

Markdown対応

  • .adoc.md
  • adocmarkdown

にするだけです。

local hook化

そのままだとMarkdown以外にも適用されます。たとえばinit.elを編集すると、この設定の(setq time-stamp-start "date: ")date: ")まで書き換わってしまいます。
StackExchangeの記事を参考に、'localをつけました。

time-stamp-format変更対応

Emacs 27.1ではそのままだと以下の警告が出ます。

The formats recognized in time-stamp-format will change in a future release
to be more compatible with the format-time-string function.

The following obsolescent time-stamp-format construct(s) were found:

"%04y" -- use %Y

%Yに変えました。

結果

上記の結果です。

(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-hook 'markdown-mode-hook (lambda()
  (require 'time-stamp)
  (add-hook 'before-save-hook 'time-stamp nil 'local)
  (setq time-stamp-active t)
  (setq time-stamp-start "date: ")
  (setq time-stamp-format "%Y-%02m-%02dT%02H:%02M:%02S%:z")
  (setq time-stamp-end "$")
))
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?