Here is a minimal configuration to get Claude working in Emacs using gptel. No frills, just the essentials to start chatting.
gptelを使用してEmacsでClaudeを動作させるための最小限の設定です。装飾なし、チャットを開始するための必要最低限のみ。
Prerequisites / 前提条件
You'll need:
必要なもの:
- • Emacs (obviously)
- • gptel package installed
- • An Anthropic API key
The Configuration / 設定
Add this to your Emacs config file:
Emacs設定ファイルにこれを追加:
;; Configure Claude - PUT YOUR KEY HERE (setq gptel-api-key "your-api-key-here") (setq gptel-backend (gptel-make-anthropic "Claude" :key gptel-api-key :stream t)) (setq gptel-model "claude-opus-4-1-20250805") (defun claude () "Start Claude chat" (interactive) (let ((buf (get-buffer-create "*Claude Chat*"))) (switch-to-buffer buf) (text-mode) ; Set text-mode FIRST (gptel-mode 1) ; THEN enable gptel-mode (when (= (buffer-size) 0) (insert "Chat with Claude\n\n")) (goto-char (point-max)) (message "Type your message and press C-c RET to send"))) (global-set-key (kbd "C-c c") 'claude)
What This Does / これが何をするか
The configuration:
この設定は:
- • Sets up gptel to use Anthropic's Claude API
- • Creates a simple `claude` command to start chatting
- • Binds it to `C-c c` for quick access
- • Uses streaming for real-time responses
Usage / 使い方
After adding the configuration:
設定を追加した後:
1. Press C-c c to open Claude chat buffer 2. Type your message 3. Press C-c RET to send 4. Wait for response
Notes / ノート
The order matters in the `claude` function — setting `text-mode` before `gptel-mode` prevents potential mode conflicts. The buffer name `*Claude Chat*` makes it easy to find in your buffer list.
`claude`関数での順序は重要です — `gptel-mode`の前に`text-mode`を設定することで、潜在的なモードの競合を防ぎます。バッファ名`*Claude Chat*`はバッファリストで見つけやすくします。
This configuration uses Claude Opus 4.1, but you can change the model string to use other Claude versions as needed.
この設定はClaude Opus 4.1を使用しますが、必要に応じてモデル文字列を変更して他のClaudeバージョンを使用できます。
That's It / 以上
Minimal setup, maximum utility. Now you can chat with Claude without leaving Emacs.
最小限のセットアップ、最大限の実用性。これでEmacsを離れることなくClaudeとチャットできます。
Ara / アラ
Questions about gptel? Check the package documentation.
gptelについて質問がありますか?パッケージのドキュメントを確認してください。