macOS に emacs-plus 30 を導入する
こんにちは。
macOS で emacs-plus 30 を入れるときにやったことをメモしておきます。
1. patch を用意する
今回は2つの patch を使います。
ns-inline: macOS の Cocoa 版 Emacs に macIM 系の拡張を取り込み、日本語 IME のインライン変換表示や入力ソース切り替えまわりを改善するパッチ1dictation: macOS の音声入力(Dictation)で確定前テキストや選択範囲を扱えるようにするパッチ23
この設定は d12frosted/homebrew-emacs-plus の README にある Build Configuration に書かれているやり方です。
~/.config/emacs-plus/build.yml(または ~/.emacs-plus-build.yml)に下記を記載しておきます。
ここではパッチを固定したかったので、dictation は一旦自分の gist に置いたものを参照しています。
patches:
- ns-inline:
url: https://raw.githubusercontent.com/takaxp/ns-inline-patch/refs/heads/master/emacs-29.1-inline.patch
sha256: 41c9e27b012848c548facd31de1ff1c71ccfa723fabb1e9395f5d469862bb5fa
- dictation:
url: https://gist.githubusercontent.com/hyakt/a2cb82eb58f0fc47ca436e0e6f343614/raw/dictation.patch
sha256: 5c66f9f519407c1489984f4e3088fff968de3a3ee4a60edb4b7e70fd01ff879c
dictation 側の修正は upstream の master(Emacs 31 系)には取り込まれているため、少なくともこの対応は Emacs 30 系までで十分そうです。
2. Homebrew で emacs-plus をインストールする
brew install d12frosted/emacs-plus@30
これで完了です。
元々は emacs-mac を使っていましたが、Emacs 30 系を使いたかったので emacs-plus に移行しました。
emacs-mac に大きな不満があったわけではないものの、自分の環境では emacs-plus の方がクラッシュが少なく、今のところ安定して動いています。
追記(2026-03-24)
macOS Tahoe + Xcode 26 系(clang -std=gnu23)だと、上の ns-inline(emacs-29.1-inline.patch)がそのままではビルドに失敗しました。
原因は src/macim.m の古い K&R 形式の関数宣言で、C23 でコンパイルエラーになります。
そのため、ns-inline の直後に C23 互換の最小パッチを 1 枚追加すると安定してビルドできます。
patches:
- ns-inline:
url: https://raw.githubusercontent.com/takaxp/ns-inline-patch/refs/heads/master/emacs-29.1-inline.patch
sha256: 41c9e27b012848c548facd31de1ff1c71ccfa723fabb1e9395f5d469862bb5fa
# C23 compatibility fix for Tahoe/Xcode 26 clang; also valid on older compilers.
- ns-inline-c23:
url: ./ns-inline-c23.patch
sha256: f2fb3de316712f0267db1a48f7c2557a354f51ea942df8b391cee6a88e6d9161
- dictation:
url: https://gist.githubusercontent.com/hyakt/a2cb82eb58f0fc47ca436e0e6f343614/raw/dictation.patch
sha256: 5c66f9f519407c1489984f4e3088fff968de3a3ee4a60edb4b7e70fd01ff879c
ns-inline-c23.patch の中身は次の差分です。
diff --git a/src/macim.m b/src/macim.m
--- a/src/macim.m
+++ b/src/macim.m
@@ -73,8 +73,7 @@ DEFUN ("mac-toggle-input-source", Fmac_toggle_input_source, Smac_toggle_input_source,
1, 1, 0,
doc: /* toggle input source on macOS */)
- (arg)
- Lisp_Object arg;
+ (Lisp_Object arg)
{
この変更は C23 より前の環境(Sonoma など)でもそのまま通る書き方なので、追加しておいて問題ありません。