Emacsで、Gitのフロントエンドとしてmagitを使う際、magit-logで表示されるコミット日時が、コミット時期(5 weeksとか1 yearとか)で表示されるけど、これをコミット時刻(2018-01-02 03:04:05)で表示させたい。
対処法: 以前のmagitの場合
きっと誰かが同じことを考えているはずと思い、ググってみたところ、magitのログで、コミット日時を時刻で表示させる設定が見つかった。これに従って設定してみたけど、magitの作りが変更されているようで、最近のmagitでは動作しない模様。
但し、どのバージョンから動作しなくなったのかまでは未調査。
対処法: 最近のmagitの場合
カスタマイズできるように、変数が用意されてないかmagitパッケージのそれらしいlispファイル(magit-log.el
)を眺めてみた所、見つかった。
(defcustom magit-log-margin '(t age magit-log-margin-width t 18)
"Format of the margin in `magit-log-mode' buffers.
The value has the form (INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH).
If INIT is non-nil, then the margin is shown initially.
STYLE controls how to format the committer date. It can be one
of `age' (to show the age of the commit), `age-abbreviated' (to
abbreviate the time unit to a character), or a string (suitable
for `format-time-string') to show the actual date.
WIDTH controls the width of the margin. This exists for forward
compatibility and currently the value should not be changed.
AUTHOR controls whether the name of the author is also shown by
default.
AUTHOR-WIDTH has to be an integer. When the name of the author
is shown, then this specifies how much space is used to do so."
ということなので、デフォルトでage
となっている箇所を、format-time-stringに適した文字列で置き換えてあげればよいらしい。
ということで、↓で解決。
(eval-after-load "magit-log"
'(progn
(custom-set-variables
'(magit-log-margin '(t "%Y-%m-%d %H:%M:%S" magit-log-margin-width t 18)))))
ちなみに、age-abbreviated
に設定すると、設定値が示しているとおり、2d, 9w, 1Yのように、コミット時期が短縮表示されるようになる。
確認環境
GNU Emacs 25.3.1
magit 20180304.1221