1
2

More than 3 years have passed since last update.

2020年しあわせ大賞:emacs + org-capture on macOS

Last updated at Posted at 2020-11-08

背景

今年はコロナでいろいろあった(まだ終わってないけど)。いちばん良かったのは「macOSでかんたんにemacsが使える」のを発見できたこと。2020年でいちばんハッピーなことだったかも(まだ終わってないけど)。

macOSはunixであると再確認できたし、Homebrewなどのパッケージ管理がすげー便利であることも知ることができた。MacBookさいこー。

macbook/emacsさいこー、と言いつつも、めっちゃコーディングをするわけでもなく。なにより便利で使い続けているのはorg-capture。まじでべんりです。

何をどうしたか、忘れそうなので記録しておく。

emacsのインストール

  1. Homebrewを使えるようにする
  2. emacsをインストールする

Homebrewを使えるようにする

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Xcodeの「command line tools」が入っていない場合は、インストールするか聞かれるのでYesを選択。ダウンロード&インストールしてくれる。

emacsをインストールする

$ brew tap railwaycat/emacsmacport
$ brew cask install emacs-mac

①emacs on terminal ②emacs with cocoa ③cask emacs ④emacs-mac があって、まあ、④emacs-macが良いみたい。理由がいまいち思い出せないんだよな。たぶん、日本語入力のときにチラつかないんだったと思う。

設定する

  • 月ごとぐらいに1ファイル作って、ここに何でも書き込む
  • このファイルから、メモもブログも生み出されてほしい
  • できれば先頭に新しいエントリが入ってほしいが、これは尚可要件 → 設定の仕方がわからないので求めない
init.el
  ;; キーバインドの設定
  (global-set-key (kbd "C-c c") 'org-capture)

  ;;ファイルパスの設定
  (setq work-directory "~/xxx/xxx/")
  (setq journalfile (concat work-directory "yymmdd_xxxx_journal.org"))

  (setq org-capture-templates
        '(
          ("j" "Journal" entry (file+datetree journalfile)
           "* %U\n%?\n%i\n"
           :empty-lines 1)
          )
        )
  (setq org-refile-targets '((journalfile :maxlevel . 3)))

使用感

メモをとる(キャプチャ)

output.gif

操作

  • (org-modeにいると、だろうか?)<C-c> c*org-select*画面になる
  • jを押すと[j] Journalテンプレートを選ぶ(テンプレはinit.elで設定してある)
  • キャプチャ画面になるので、適当に書いて<C-c><C-c>するとjournal.orgファイルに書き込まれる(書き込み先はinit.elで設定してある)
  • キャプチャ画面で<C-c><C-k>すると、書いたものを破棄

参考サイト

主にemacsのインストール

homebrewからインストールできるemacsの違い

Mac で emacs を使ってみる 2020年度版

Emacs Mac PortをHomebrewからインストールする

主にorg-mode, org-capture

モーレツ! ORG MODE 教室 その1: 素早くメモを取る

org-captureをカスタマイズして、すばやくメモを取る方法

Org-modeで、ライフログを録ろう

モーレツ! ORG MODE 教室 その2: まとまった文章を書く

org-mode 私の使い方

自分の作業ログより

虎(牛)龍未酉2.1

環境

GNU Emacs 27.1 (build 1, x86_64-apple-darwin19.6.0, Carbon Version 162 AppKit 1894.6) of 2020-11-05
macOS Catalina バージョン 10.15.7(19H2)
MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)

1
2
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
1
2