LoginSignup
5
4

More than 5 years have passed since last update.

Spacemacsでさくっとタイムスタンプを打つ

Last updated at Posted at 2017-02-12

Spacemacsを使っているとき、タイムスタンプを挿入したいなら、さくっとuser-initに関数を定義すると良さそうです。

タイムスタンプを挿入する関数といえば、org-time-stampが挙げられますが、表示形式が<2017-02-13 Mon>となります。時刻まで入れたいときは、手動で入力が必要で面倒です。もっと便利な関数がEmacsでは用意されていると思ったのですが、Spacemacsでは動かし方がわかりませんでした。

Spacemacsに新しく関数を定義する

$HOME/.spacemacsdotspacemacs/user-initに以下の関数定義を追加します。

(defun my/insert-time-stamp ()
  "Insert TimeStamp"
  (interactive)
  (insert (current-time-string)))

M-x my/insert-time-stampとして呼び出すとカレントバッファにMon Feb 13 01:06:02 2017が挿入されます。これで快適Emacsメモ生活が送れますね :tada:

補遺: 日付時刻フォーマット変更にはformat-time-stringを使う

current-time-stringの代わりにformat-time-stringを使うと、日付時刻フォーマットを指定することができます。

5
4
2

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
5
4