📝

EmacsからClaudeCodeを使う

に公開

Cline/RooCodeやGithubCopilotAgentなど、VSCodeを前提とした環境が増えてきているので、
今年はEmacsから離れてVSCodeに移行しようかと思ってましたが
ClaudeCodeを使い始めて、やっぱりEmacsでいいや、と戻ってきてしまいました。

普通にTerminalからClaudeCode使っていてもそこまで不便はないんですが
なんでもかんでもEmacsを使いたいので、Emacs上から使えるようにしてみたいと思います。

calude-code.el

https://github.com/stevemolitor/claude-code.el

さて、こちらを使わせていただこうかと思ったんですが

Prerequisites

  • Emacs 30.0 or higher
  • Claude Code CLI installed and configured
  • Required Emacs packages: transient (0.4.0+), eat (0.9.2+)

とのことで、、、
残念ながら私は emacs-mac(いわゆるEMP版) を使っているので、まだ 29.1 です。
2025/06/11 時点で、emacs-macでは、emacs-29.1-mac-10.0 が最新でした。
というわけで、まずはEmacsをv30まで上げます。

emacs-plusを使う

https://emacs-jp.github.io/tips/versions#macos
こちらでも紹介されている、 emacs-plus を使います。

brew tap d12frosted/emacs-plus
brew install emacs-plus@30 --with-imagemagick
...
mv /Applications/Emacs.app /Applications/Emacs-old.app
cp -r /opt/homebrew/opt/emacs-plus@30/Emacs.app /Applications/

これで、emacsが 30.1 になりました。

❯ emacs --version
GNU Emacs 30.1
Copyright (C) 2025 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

claude-code.elをインストール

ClaudeCode CLIはインストール済みとします。

  • Required Emacs packages: transient (0.4.0+), eat (0.9.2+)

とREADMEに書いてあります。
eat は、NonGNU ELPAにしかないようなので
NonGNU ELPA - eat
package-archives("nongnu" . "https://elpa.nongnu.org/nongnu/") を追加しておきます。

leaf.elの場合はこんな感じ

init.el
;; <leaf-install-code>
(eval-and-compile
  (customize-set-variable
   'package-archives '(("org" . "https://orgmode.org/elpa/")
                       ("melpa" . "https://melpa.org/packages/")
                       ("gnu" . "https://elpa.gnu.org/packages/")
                       ("nongnu" . "https://elpa.nongnu.org/nongnu/"))) ;; ここ!
  (package-initialize)
  (unless (package-installed-p 'leaf)
    (package-refresh-contents)
    (package-install 'leaf))

  (leaf leaf-keywords
    :ensure t
    :init
    ;; optional packages if you want to use :hydra, :el-get, :blackout,,,
    (leaf hydra :ensure t)
    (leaf el-get :ensure t)
    (leaf blackout :ensure t)

    :config
    ;; initialize leaf-keywords.el
    (leaf-keywords-init)))
;; </leaf-install-code>

そして、leafでインストールします。

init.el
;; Claude Code
(leaf transient
  :ensure t)
(leaf eat
  :ensure t)
(leaf claude-code
  :req "transient-0.7.5" "eat-0.9.2"
  :vc (:url "https://github.com/stevemolitor/claude-code.el")
  )

使ってみた感想

特にEmacsから使う必要性は感じなかったですね。。。
特に、フォントサイズを大きく設定していたりすると、かなりガタガタにズレます。

  • VSCodeから使う
  • Terminalから使う

のどちらかのほうが今は良いと思いました。
今回はEmacsのバージョンを上げられた、という成果のみで満足することにします 🙇

Discussion