[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-stevemolitor--claude-code.el":3,"tool-stevemolitor--claude-code.el":64},[4,17,27,35,44,52],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",150037,2,"2026-04-10T23:33:47",[13,14,15],"开发框架","Agent","语言模型","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":10,"last_commit_at":23,"category_tags":24,"status":16},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[25,14,26,13],"插件","图像",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":10,"last_commit_at":33,"category_tags":34,"status":16},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[25,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":41,"last_commit_at":42,"category_tags":43,"status":16},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,3,"2026-04-06T11:19:32",[15,26,14,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,15],{"id":53,"name":54,"github_repo":55,"description_zh":56,"stars":57,"difficulty_score":10,"last_commit_at":58,"category_tags":59,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",85092,"2026-04-10T11:13:16",[26,60,61,25,14,62,15,13,63],"数据工具","视频","其他","音频",{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":78,"owner_location":78,"owner_email":79,"owner_twitter":78,"owner_website":78,"owner_url":80,"languages":81,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":98,"env_os":99,"env_gpu":100,"env_ram":101,"env_deps":102,"category_tags":113,"github_topics":78,"view_count":10,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":114,"updated_at":115,"faqs":116,"releases":146},6466,"stevemolitor\u002Fclaude-code.el","claude-code.el","Claude Code Emacs integration","claude-code.el 是一款专为 Emacs 用户打造的 AI 编程助手插件，它将 Anthropic 的 Claude Code 命令行工具无缝集成到编辑器中。对于习惯在 Emacs 环境中工作的开发者而言，它解决了频繁切换窗口以与 AI 交互的痛点，让你无需离开当前代码缓冲区即可发送代码片段、区域或指令给 Claude，并即时获取修复建议或生成代码。\n\n这款工具特别适合深度依赖 Emacs 进行软件开发的工程师和研究人员。其核心亮点在于高度的上下文感知能力：它能自动附带文件路径和行号，帮助 Claude 更精准地理解问题；支持多实例会话管理，方便同时处理不同项目；还具备独特的“瞬态菜单”和快捷键回复机制，让用户能像操作原生功能一样流畅地与 AI 对话。此外，它兼容 eat 和 vterm 多种终端后端，并提供桌面通知、只读模式切换及可定制的编辑策略（如自动接受或规划模式），真正实现了在熟悉的编辑环境中享受智能编码辅助的高效体验。","# claude-code.el\n\nAn Emacs interface for [Claude Code CLI](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code), providing integration between Emacs and Claude AI for coding assistance.\n\n## Features\n\n- **Seamless Emacs Integration** - Start, manage, and interact with Claude without leaving Emacs\n- **Stay in Your Buffer** - Send code, regions, or commands to Claude while keeping your focus\n- **Fix Errors Instantly** - Point at a flycheck\u002Fflymake error and ask Claude to fix it\n- **Multiple Instances** - Run separate Claude sessions for different projects or tasks\n- **Quick Responses** - Answer Claude with a keystroke (\u003Creturn>\u002F\u003Cescape>\u002F1\u002F2\u002F3) without switching buffers\n- **Smart Context** - Optionally include file paths and line numbers when sending commands to Claude\n- **Transient Menu** - Access all commands and slash commands through a transient menu\n- **Continue Conversations** - Resume previous sessions or fork to earlier points\n- **Read-Only Mode** - Toggle to select and copy text with normal Emacs commands and keybindings\n- **Mode Cycling** - Quick switch between default, auto-accept edits, and plan modes\n- **Desktop Notifications** - Get notified when Claude finishes processing\n- **Terminal Choice** - Works with both eat and vterm backends\n- **Fully Customizable** - Configure keybindings, notifications, and display preferences\n\n## Installation\n\n### Prerequisites\n\n- Emacs 30.0 or higher\n- [Claude Code CLI](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code) installed and configured\n- Required: transient (0.7.5+) inheritenv (0.2)\n- Optional: eat (0.9.2+) for eat backend, vterm for vterm backend\n  - Note: If not using a `:vc` install, the `eat` package requires NonGNU ELPA:\n    ```elisp\n    (add-to-list 'package-archives '(\"nongnu\" . \"https:\u002F\u002Felpa.nongnu.org\u002Fnongnu\u002F\"))\n    ```\n- Optional but recommended: [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) for IDE integration\n\n### Using builtin use-package (Emacs 30+)\n\n```elisp\n;; add melpa to package archives, as vterm is on melpa:\n(require 'package)\n(add-to-list 'package-archives '(\"melpa\" . \"https:\u002F\u002Fmelpa.org\u002Fpackages\u002F\") t)\n(package-initialize)\n\n;; install required inheritenv dependency:\n(use-package inheritenv\n  :vc (:url \"https:\u002F\u002Fgithub.com\u002Fpurcell\u002Finheritenv\" :rev :newest))\n\n;; for eat terminal backend:\n(use-package eat :ensure t)\n\n;; for vterm terminal backend:\n(use-package vterm :ensure t)\n\n;; install claude-code.el\n(use-package claude-code :ensure t\n  :vc (:url \"https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\" :rev :newest)\n  :config\n  ;; optional IDE integration with Monet\n  (add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n  (monet-mode 1)\n\n  (claude-code-mode)\n  :bind-keymap (\"C-c c\" . claude-code-command-map)\n\n  ;; Optionally define a repeat map so that \"M\" will cycle thru Claude auto-accept\u002Fplan\u002Fconfirm modes after invoking claude-code-cycle-mode \u002F C-c M.\n  :bind\n  (:repeat-map my-claude-code-map (\"M\" . claude-code-cycle-mode)))\n```\n\n### Using straight.el\n\n```elisp\n;; install required inheritenv dependency:\n(use-package inheritenv\n  :straight (:type git :host github :repo \"purcell\u002Finheritenv\"))\n\n;; for eat terminal backend:\n(use-package eat\n  :straight (:type git\n                   :host codeberg\n                   :repo \"akib\u002Femacs-eat\"\n                   :files (\"*.el\" (\"term\" \"term\u002F*.el\") \"*.texi\"\n                           \"*.ti\" (\"terminfo\u002Fe\" \"terminfo\u002Fe\u002F*\")\n                           (\"terminfo\u002F65\" \"terminfo\u002F65\u002F*\")\n                           (\"integration\" \"integration\u002F*\")\n                           (:exclude \".dir-locals.el\" \"*-tests.el\"))))\n\n;; for vterm terminal backend:\n(use-package vterm :straight t)\n\n;; install claude-code.el, using :depth 1 to reduce download size:\n(use-package claude-code\n  :straight (:type git :host github :repo \"stevemolitor\u002Fclaude-code.el\" :branch \"main\" :depth 1\n                   :files (\"*.el\" (:exclude \"images\u002F*\")))\n  :bind-keymap\n  (\"C-c c\" . claude-code-command-map) ;; or your preferred key\n  ;; Optionally define a repeat map so that \"M\" will cycle thru Claude auto-accept\u002Fplan\u002Fconfirm modes after invoking claude-code-cycle-mode \u002F C-c M.\n  :bind\n  (:repeat-map my-claude-code-map (\"M\" . claude-code-cycle-mode))\n  :config\n  ;; optional IDE integration with Monet\n  (add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n  (monet-mode 1)\n\n  (claude-code-mode))\n```\n\n## Basic Usage\n\n### Setting Prefix Key\nYou need to set your own key binding for the Claude Code command map, as described in the [Installation](#installation) section. The examples in this README use `C-c c` as the prefix key.\n\n### Picking Eat or Vterm\n\nBy default claude-code.el uses the `eat` backend. If you prefer vterm customize\n`claude-code-terminal-backend`:\n\n```elisp\n(setq claude-code-terminal-backend 'vterm)\n```\n\n### Transient Menu\n\nYou can see a menu of the important commands by invoking the transient, `claude-code-transient` (`C-c c m`):\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fstevemolitor_claude-code.el_readme_e35ecc0a0583.png)\n\n### Starting and Stopping Claude\n\nTo start Claude, run `claude-code` (`C-c c c`). This will start a new Claude instance in the root\nproject directory of the buffer file, or the current directory if outside of a project.\nClaude-code.el uses Emacs built-in\n[project.el](https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Femacs\u002Fmanual\u002Fhtml_node\u002Femacs\u002FProjects.html) which works\nwith most version control systems.\n\nTo start Claude in a specific directory use `claude-code-start-in-directory` (`C-c c d`). It will\nprompt you for the directory.\n\nThe `claude-code-continue` command will continue the previous conversation, and `claude-code-resume` will let you pick from a list of previous sessions.\n\nTo kill the Claude process and close its window use `claude-code-kill` (`C-c c k`).\n\n### Sending Commands to Claude\n\nOnce Claude has started, you can switch to the Claude buffer and start entering prompts.\nAlternately, you can send prompts to Claude using the minibuffer via `claude-code-send-command`\n(`C-c c s`). `claude-code-send-command-with-context` (`C-c c x`) will also send the current file name and line\nnumber to Claude. This is useful for asking things like \"what does this code do?\", or \"fix the bug\nin this code\".\n\nUse the `claude-code-send-region` (`C-c c r`) command to send the selected region to Claude, or the entire buffer if no region is selected. This command is useful for writing a prompt in a regular Emacs buffer and sending it to Claude. With a single prefix arg (`C-u C-c c r`) it will prompt for extra context before sending the region to Claude.\n\nYou can also send files directly to Claude using `claude-code-send-file` to send any file by path, or `claude-code-send-buffer-file` (`C-c c o`) to send the file associated with the current buffer. The `claude-code-send-buffer-file` command supports prefix arguments similar to `claude-code-send-region` - with a single prefix arg it prompts for instructions, and with double prefix it also switches to the Claude buffer.\n\nIf you put your cursor over a flymake or flycheck error, you can ask Claude to fix it via `claude-code-fix-error-at-point` (`C-c c e`).\n\nTo show and hide the Claude buffer use `claude-code-toggle` (`C-c c t`).  To jump to the Claude buffer use `claude-code-switch-to-buffer` (`C-c c b`). This will open the buffer if hidden.\n\n### Managing Claude Windows\n\nThe `claude-code-toggle` (`C-c c t`) will show and hide the Claude window. Use the `claude-code-switch-to-buffer` (`C-c c b`) command to switch to the Claude window even if it is hidden. \n\nTo enter read-only mode in the Claude buffer use `claude-code-toggle-read-only-mode` (`C-c c z`). In this mode you can select and copy text, and use regular Emacs keybindings. To exit read-only mode invoke `claude-code-toggle-read-only-mode` again.\n\n### Quick Responses\n\nSometimes you want to send a quick response to Claude without switching to the Claude buffer. The following commands let you answer a query from Claude without leaving your current editing buffer:\n\n- `claude-code-send-return` (`C-c c y`) - send the return or enter key to Claude, commonly used to respond with \"Yes\" to Claude queriesy\n- `claude-code-send-escape` (`C-c c n`) - send the escape key, to say \"No\" to Claude or to cancel a running Claude action\n- `claude-code-send-1` (`C-c c 1`) - send \"1\" to Claude, to choose option \"1\" in response to a Claude query\n- `claude-code-send-2` (`C-c c 2`) - send \"2\" to Claude\n- `claude-code-send-3` (`C-c c 3`) - send \"3\" to Claude\n\n## IDE Integration with [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet)\nYou can optionally use [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) for IDE integration. To integrate Monet with Claude do this (or the equivalent `use-package` declaration shown above):\n\n```elisp\n(add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n(monet-mode 1)\n```\n\nWhen Claude starts a new instance it will automatically start a Monet websocket server to listen to and send IDE comments to\u002Ffrom Claude. Current selection will automatically be sent to Claude, and Claude will show diffs in Emacs, use Emacs Monet tools to open files, get diagnostics, etc. See the [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) documentation for more details.\n\n## Working with Multiple Claude Instances\n\n`claude-code.el` supports running multiple Claude instances across different projects and directories. Each Claude instance is associated with a specific directory (project root, file directory, or current directory).\n\n#### Instance Management\n\n- When you start Claude with `claude-code`, it creates an instance for the current directory\n- If a Claude instance already exists for the directory, you'll be prompted to name the new instance (e.g., \"tests\", \"docs\")\n- You can also use `claude-code-new-instance` to explicitly create a new instance with a custom name\n- Buffer names follow the format:\n  - `*claude:\u002Fpath\u002Fto\u002Fdirectory:instance-name*` (e.g., `*claude:\u002Fhome\u002Fuser\u002Fproject:tests*`)\n- If you're in a directory without a Claude instance but have instances running in other directories, you'll be prompted to select one\n- Your selection is remembered for that directory, so you won't be prompted again\n\n### Instance Selection\n\nCommands that operate on an instance (`claude-send-command`, `claude-code-switch-to-buffer`, `claude-code-kill`, etc.) will prompt you for the Claude instance if there is more than one instance associated with the current buffer's project.\n\nIf the buffer file is not associated with a running Claude instance, you can select an instance running in a different project. This is useful when you want Claude to analyze dependent projects or files that you have checked out in sibling directories.\n\nClaude-code.el remembers which buffers are associated with which Claude instances, so you won't be repeatedly prompted. This association also helps claude-code.el \"do the right thing\" when killing a Claude process and deleting its associated buffer.\n\n### Multiple Instances Per Directory\n\nYou can run multiple Claude instances for the same directory to support different workflows:\n\n- The first instance in a directory is the \"default\" instance\n- Additional instances require a name when created (e.g., \"tests\", \"docs\", \"refactor\")\n- When multiple instances exist for a directory, commands that interact with Claude will prompt you to select which instance to use\n- Use `C-u claude-code-switch-to-buffer` to see all Claude instances across all directories (not just the current directory)\n- Use `claude-code-select-buffer` as a dedicated command to always show all Claude instances across all directories\n\nThis allows you to have separate Claude conversations for different aspects of your work within the same project, such as one instance for writing code and another for writing tests.\n\n## Working in the Claude Buffer\n\nclaude-code.el is designed to support using Claude Code in Emacs using the minibuffer and regular Emacs buffers, with normal keybindings and full Emacs editing facilities. However, claude-code.el also adds a few niceties for working in the Claude Code terminal buffer:\n\nYou can type `C-g` as an alternative to escape. Also claude-code.el supports several options for\nentering newlines in the Claude Code session:\n\n- **Default (newline-on-shift-return)**: Press `Shift-Return` to insert a newline, `Return` to send your message\n- **Alt-return style**: Press `Alt-Return` to insert a newline, `Return` to send\n- **Shift-return to send**: Press `Return` to insert a newline, `Shift-Return` to send\n- **Super-return to send**: Press `Return` to insert a newline, `Command-Return` (macOS) to send\n\nYou can change this behavior by customizing `claude-code-newline-keybinding-style` (see [Customization](#customization)).\n\n### Command Reference\n\n- `claude-code-transient` (`C-c c m`) - Show all commands (transient menu)\n- `claude-code` (`C-c c c`) - Start Claude. With prefix arg (`C-u`), switches to the Claude buffer after creating. With double prefix (`C-u C-u`), prompts for the project directory\n- `claude-code-start-in-directory` (`C-c c d`) - Prompt for a directory and start Claude there. With prefix arg (`C-u`), switches to the Claude buffer after creating\n- `claude-code-continue` (`C-c c C`) - Start Claude and continue the previous conversation. With prefix arg (`C-u`), switches to the Claude buffer after creating. With double prefix (`C-u C-u`), prompts for the project directory\n- `claude-code-resume` (`C-c c R`) - Resume a specific Claude session from an interactive list. With prefix arg (`C-u`), switches to the Claude buffer after creating. With double prefix (`C-u C-u`), prompts for the project directory\n- `claude-code-new-instance` (`C-c c i`) - Create a new Claude instance with a custom name. Always prompts for instance name, unlike `claude-code` which uses \"default\" when no instances exist. With prefix arg (`C-u`), switches to the Claude buffer after creating. With double prefix (`C-u C-u`), prompts for the project directory\n- `claude-code-kill` (`C-c c k`) - Kill Claude session\n- `claude-code-kill-all` (`C-c c K`) - Kill ALL Claude instances across all directories\n- `claude-code-send-command` (`C-c c s`) - Send command to Claude. With prefix arg (`C-u`), switches to the Claude buffer after sending\n- `claude-code-send-command-with-context` (`C-c c x`) - Send command with current file and line context. With prefix arg (`C-u`), switches to the Claude buffer after sending\n- `claude-code-send-region` (`C-c c r`) - Send the current region or buffer to Claude. With prefix arg (`C-u`), prompts for instructions to add to the text. With double prefix (`C-u C-u`), adds instructions and switches to Claude buffer\n- `claude-code-send-file` - Send a specified file to Claude. Prompts for file path\n- `claude-code-send-buffer-file` (`C-c c o`) - Send the file associated with current buffer to Claude. With prefix arg (`C-u`), prompts for instructions to add to the file. With double prefix (`C-u C-u`), adds instructions and switches to Claude buffer\n- `claude-code-fix-error-at-point` (`C-c c e`) - Ask Claude to fix the error at the current point (works with flycheck, flymake, and any system that implements help-at-pt). With prefix arg (`C-u`), switches to the Claude buffer after sending\n- `claude-code-fork` (`C-c c f`) - Fork conversation (jump to previous conversation by sending escape-escape to Claude)\n- `claude-code-slash-commands` (`C-c c \u002F`) - Access Claude slash commands menu\n- `claude-code-toggle` (`C-c c t`) - Toggle Claude window\n- `claude-code-switch-to-buffer` (`C-c c b`) - Switch to the Claude buffer. With prefix arg (`C-u`), shows all Claude instances across all directories\n- `claude-code-select-buffer` (`C-c c B`) - Select and switch to a Claude buffer from all running instances across all projects and directories\n- `claude-code-toggle-read-only-mode` (`C-c c z`) - Toggle between read-only mode and normal mode in Claude buffer (useful for selecting and copying text)\n- `claude-code-cycle-mode` (`C-c c M`) - Send Shift-Tab to Claude to cycle between default mode, auto-accept edits mode, and plan mode. See the installation section above to configure a repeat map so that you can cycle thru the modes with \"M\" after the initial invocation.\n\n- `claude-code-send-return` (`C-c c y`) - Send return key to Claude (useful for confirming with Claude without switching to the Claude REPL buffer) (useful for responding with \"Yes\"  to Claude)\n- `claude-code-send-escape` (`C-c c n`) - Send escape key to Claude (useful for saying \"No\" when Claude asks for confirmation without switching to the Claude REPL buffer)\n- `claude-code-send-1` (`C-c c 1`) - Send \"1\" to Claude (useful for selecting the first option when Claude presents a numbered menu)\n- `claude-code-send-2` (`C-c c 2`) - Send \"2\" to Claude (useful for selecting the second option when Claude presents a numbered menu)\n- `claude-code-send-3` (`C-c c 3`) - Send \"3\" to Claude (useful for selecting the third option when Claude presents a numbered menu)\n\n## Desktop Notifications\n\nclaude-code.el notifies you when Claude finishes processing and is waiting for input. By default, it displays a message in the minibuffer and pulses the modeline for visual feedback.\n\n### macOS Native Notifications\n\nTo use macOS native notifications with sound, add this to your configuration:\n\n```elisp\n(defun my-claude-notify (title message)\n  \"Display a macOS notification with sound.\"\n  (call-process \"osascript\" nil nil nil\n                \"-e\" (format \"display notification \\\"%s\\\" with title \\\"%s\\\" sound name \\\"Glass\\\"\"\n                             message title)))\n\n(setq claude-code-notification-function #'my-claude-notify)\n```\n\nThis will display a system notification with a \"Glass\" sound effect when Claude is ready. You can change the sound name to any system sound (e.g., \"Ping\", \"Hero\", \"Morse\", etc.) or remove the `sound name` part for silent notifications.\n\n### Linux Native Notifications\n\nFor Linux desktop notifications, you can use `notify-send` (GNOME\u002FUnity) or `kdialog` (KDE):\n\n```elisp\n;; For GNOME\u002FUnity desktops\n(defun my-claude-notify (title message)\n  \"Display a Linux notification using notify-send.\"\n  (if (executable-find \"notify-send\")\n      (call-process \"notify-send\" nil nil nil title message)\n    (message \"%s: %s\" title message)))\n\n(setq claude-code-notification-function #'my-claude-notify)\n```\n\nTo add sound on Linux:\n\n```elisp\n(defun my-claude-notify-with-sound (title message)\n  \"Display a Linux notification with sound.\"\n  (when (executable-find \"notify-send\")\n    (call-process \"notify-send\" nil nil nil title message))\n  ;; Play sound if paplay is available\n  (when (executable-find \"paplay\")\n    (call-process \"paplay\" nil nil nil \"\u002Fusr\u002Fshare\u002Fsounds\u002Ffreedesktop\u002Fstereo\u002Fmessage.oga\")))\n\n(setq claude-code-notification-function #'my-claude-notify-with-sound)\n```\n\n### Windows Native Notifications\n\nFor Windows, you can use PowerShell to create toast notifications:\n\n```elisp\n(defun my-claude-notify (title message)\n  \"Display a Windows notification using PowerShell.\"\n  (call-process \"powershell\" nil nil nil\n                \"-NoProfile\" \"-Command\"\n                (concat \"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null; \"\n                        \"$template = '\u003Ctoast>\u003Cvisual>\u003Cbinding template=\\\"ToastGeneric\\\">\u003Ctext>\" title \"\u003C\u002Ftext>\u003Ctext>\" message \"\u003C\u002Ftext>\u003C\u002Fbinding>\u003C\u002Fvisual>\u003C\u002Ftoast>'; \"\n                        \"$xml = New-Object Windows.Data.Xml.Dom.XmlDocument; \"\n                        \"$xml.LoadXml($template); \"\n                        \"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml); \"\n                        \"[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('Emacs').Show($toast)\")))\n\n(setq claude-code-notification-function #'my-claude-notify)\n```\n\n*Note: Linux and Windows examples are untested. Feedback and improvements are welcome!*\n\n### Claude Code Hooks Integration\n\nclaude-code.el provides integration to **receive** hook events from Claude Code CLI via emacsclient. \n\nSee [`examples\u002Fhooks\u002Fclaude-code-hook-examples.el`](examples\u002Fhooks\u002Fclaude-code-hook-examples.el) for comprehensive examples of hook listeners and setup functions.\n\n#### Hook API\n\n- `claude-code-event-hook` - Emacs hook run when Claude Code CLI triggers events\n- `claude-code-handle-hook` - **Unified entry point** for all Claude Code CLI hooks. Call this from your CLI hooks with `(type buffer-name &rest args)` and JSON data as additional emacsclient arguments\n\n#### JSON Response System\n\nHooks can return structured JSON data to control Claude Code behavior using `run-hook-with-args-until-success`:\n\n1. **Multiple handlers**: Register multiple functions on `claude-code-event-hook`\n2. **Sequential execution**: Functions are called in order with the message data  \n3. **First response wins**: Execution stops when a function returns non-nil JSON\n4. **Bidirectional communication**: The JSON response is sent back to Claude Code CLI\n\nThis enables interactive workflows like permission prompts where hooks can influence Claude's behavior.\n\n#### Setup\n\n1. **Add the bin directory to your PATH** (required for hook wrapper script):\n   ```bash\n   export PATH=\"\u002Fpath\u002Fto\u002Fclaude-code.el\u002Fbin:$PATH\"\n   ```\n   Add this to your bash configuration file (~\u002F.bashrc, ~\u002F.bash_profile, etc.) since Claude Code needs it in the bash environment.\n\n2. **Start the Emacs server** so that `emacsclient` can communicate with your Emacs instance:\n   ```elisp\n   ;; Start the Emacs server (add this to your init.el)\n   (start-server)\n\n   ;; Add your hook listeners using standard Emacs functions\n   (add-hook 'claude-code-event-hook 'my-claude-hook-listener)\n   ```\n\n#### Custom Hook Listener\n\nHook listeners receive a message plist with these keys:\n- `:type` - Hook type (e.g., `'notification`, `'stop`, `'pre-tool-use`, `'post-tool-use`)\n- `:buffer-name` - Claude buffer name from `$CLAUDE_BUFFER_NAME`\n- `:json-data` - JSON payload from Claude CLI\n- `:args` - List of additional arguments (when using extended configuration)\n\n```elisp\n;; Define your own hook listener function\n(defun my-claude-hook-listener (message)\n  \"Custom listener for Claude Code hooks.\nMESSAGE is a plist with :type, :buffer-name, :json-data, and :args keys.\"\n  (let ((hook-type (plist-get message :type))\n        (buffer-name (plist-get message :buffer-name))\n        (json-data (plist-get message :json-data))\n        (args (plist-get message :args)))\n    (cond \n     ((eq hook-type 'notification)\n      (message \"Claude is ready in %s! JSON: %s\" buffer-name json-data))\n     ((eq hook-type 'stop)  \n      (message \"Claude finished in %s! JSON: %s\" buffer-name json-data))\n     (t\n      (message \"Claude hook: %s with JSON: %s\" hook-type json-data)))))\n\n;; Add the hook listener using standard Emacs hook functions\n(add-hook 'claude-code-event-hook 'my-claude-hook-listener)\n```\n\nSee the examples file for complete listeners that demonstrate notifications, logging, org-mode integration, and using extra arguments from the `:args` field.\n\n#### Claude Code CLI Configuration\n\nConfigure Claude Code CLI hooks to call `claude-code-handle-hook` via emacsclient by passing JSON data as an additional argument:\n\n```json\n{\n  \"hooks\": {\n    \"Notification\": [\n      {\n        \"matcher\": \"\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"emacsclient --eval \\\"(claude-code-handle-hook 'notification \\\\\\\"$CLAUDE_BUFFER_NAME\\\\\\\")\\\" \\\"$(cat)\\\"\"\n          }\n        ]\n      }\n    ],\n    \"Stop\": [\n      {\n        \"matcher\": \"\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"emacsclient --eval \\\"(claude-code-handle-hook 'stop \\\\\\\"$CLAUDE_BUFFER_NAME\\\\\\\")\\\" \\\"$(cat)\\\"\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nThe command pattern:  \n```bash\nemacsclient --eval \"(claude-code-handle-hook 'notification \\\"$CLAUDE_BUFFER_NAME\\\")\" \"$(cat)\" \"ARG1\" \"ARG2\" \"ARG3\"\n```\n\nWhere:\n- `\"$(cat)\"` - JSON data from stdin (always required)\n- `ARG1` is `\"$PWD\"` - current working directory  \n- `ARG2` is `\"$(date -Iseconds)\"` - timestamp\n- `ARG3` is `\"$$\"` - process ID\n\n`claude-code-handle-hook` creates a message plist sent to listeners:\n```elisp\n(list :type 'notification \n      :buffer-name \"$CLAUDE_BUFFER_NAME\"\n      :json-data \"$(cat)\" \n      :args '(\"ARG1\" \"ARG2\" \"ARG3\"))\n```\n\nSee the [Claude Code hooks documentation](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fhooks) for details on setting up CLI hooks.\n\n## Tips and Tricks\n\n- **Paste images**: Use `C-v` to paste images into the Claude window. Note that on macOS, this is `Control-v`, not `Command-v`.\n- **Paste text**: Use `C-y` (`yank`) to paste text into the Claude window. \n- **Save files before sending commands**: Claude reads files directly from disk, not from Emacs buffers. Always save your files (`C-x C-s`) before sending commands that reference file content. Consider enabling `global-auto-revert-mode` to automatically sync Emacs buffers with file changes made by Claude:\n  ```elisp\n  (global-auto-revert-mode 1)\n  ;; If files aren't reliably auto-reverting after Claude makes changes,\n  ;; disable file notification and use polling instead:\n  (setq auto-revert-use-notify nil)\n  ```\n- **Auto-revert with hooks**: For more control over buffer reverting, use the auto-revert hook example that listens for Claude's file edits:\n  ```elisp\n  ;; Load the auto-revert hook\n  (load-file \"examples\u002Fhooks\u002Fclaude-code-auto-revert-hook.el\")\n  ;; Set up auto-revert (choose one):\n  (setup-claude-auto-revert)           ; Safe mode - skips modified buffers\n  (setup-claude-auto-revert-aggressive) ; Prompts to revert modified buffers\n  (setup-claude-auto-revert-org)       ; Special handling for org files\n  ```\n  Then configure the PostToolUse hook in your `~\u002F.claude\u002Fsettings.json` (see `examples\u002Fhooks\u002Fauto-revert-settings.json`) \n\n## Customization\n\n```elisp\n;; Set your key binding for the command map.\n(global-set-key (kbd \"C-c C-a\") claude-code-command-map)\n\n;; Set terminal type for the Claude terminal emulation (default is \"xterm-256color\").\n;; This determines terminal capabilities like color support.\n;; See the documentation for eat-term-name for more information.\n(setq claude-code-term-name \"xterm-256color\")\n\n;; Change the path to the Claude executable (default is \"claude\").\n;; Useful if Claude is not in your PATH or you want to use a specific version.\n(setq claude-code-program \"\u002Fusr\u002Flocal\u002Fbin\u002Fclaude\")\n\n;; Set command line arguments for Claude\n;; For example, to enable verbose output\n(setq claude-code-program-switches '(\"--verbose\"))\n\n;; Add hooks to run after Claude is started\n(add-hook 'claude-code-start-hook 'my-claude-setup-function)\n\n;; Adjust initialization delay (default is 0.1 seconds)\n;; This helps prevent terminal layout issues if the buffer is displayed before Claude is fully ready.\n(setq claude-code-startup-delay 0.2)\n\n;; Configure the buffer size threshold for confirmation prompt (default is 100000 characters)\n;; If a buffer is larger than this threshold, claude-code-send-region will ask for confirmation\n;; before sending the entire buffer to Claude.\n(setq claude-code-large-buffer-threshold 100000)\n\n;; Configure key binding style for entering newlines and sending messages in Claude buffers.\n;; Available styles:\n;;   'newline-on-shift-return - S-return inserts newline, RET sends message (default)\n;;   'newline-on-alt-return   - M-return inserts newline, RET sends message\n;;   'shift-return-to-send    - RET inserts newline, S-return sends message\n;;   'super-return-to-send    - RET inserts newline, s-return sends message (Command+Return on macOS)\n(setq claude-code-newline-keybinding-style 'newline-on-shift-return)\n\n;; Enable or disable notifications when Claude finishes and awaits input (default is t).\n(setq claude-code-enable-notifications t)\n\n;; Customize the notification function (default is claude-code--default-notification).\n;; The function should accept two arguments: title and message.\n;; The default function displays a message and pulses the modeline for visual feedback.\n(setq claude-code-notification-function 'claude-code--default-notification)\n\n;; Example: Use your own notification function\n(defun my-claude-notification (title message)\n  \"Custom notification function for Claude Code.\"\n  ;; Your custom notification logic here\n  (message \"[%s] %s\" title message))\n(setq claude-code-notification-function 'my-claude-notification)\n\n;; Configure kill confirmation behavior (default is t).\n;; When t, claude-code-kill prompts for confirmation before killing instances.\n;; When nil, kills Claude instances without confirmation.\n(setq claude-code-confirm-kill t)\n\n;; Enable\u002Fdisable window resize optimization (default is t)\n;; When enabled, terminal reflows are only triggered when window width changes,\n;; not when only height changes. This prevents unnecessary redraws when splitting\n;; windows vertically, improving performance and reducing visual artifacts.\n;; Set to nil if you experience issues with terminal display after resizing.\n(setq claude-code-optimize-window-resize t)\n\n;; Enable\u002Fdisable no-delete-other-windows parameter (default is nil)\n;; When enabled, Claude Code windows have the no-delete-other-windows\n;; parameter set. This prevents the Claude window from being closed\n;; when you run delete-other-windows or similar commands, keeping the\n;; Claude buffer visible and accessible.\n(setq claude-code-no-delete-other-windows t)\n\n;; Automatically select the Claude buffer when toggling it open (default is nil)\n;; When set to t, claude-code-toggle will switch focus to the Claude buffer\n;; after displaying it. When nil, the buffer is displayed but focus remains\n;; in the current buffer.\n(setq claude-code-toggle-auto-select t)\n```\n\n### Customizing Window Position\n\n#### Using the Display Window Function\n\nYou can customize how Claude Code windows are displayed by setting `claude-code-display-window-fn`. This function is called with the Claude buffer and should display it appropriately:\n\n```elisp\n;; Use display-buffer with custom configuration\n(setq claude-code-display-window-fn #'display-buffer)\n\n;; Example: Display in a side window using popwin\n(setq claude-code-display-window-fn #'display-buffer)\n(let ((buffer-regexp \"^\\\\*claude:.+:.+\\\\*$\"))\n  (push `(,buffer-regexp :regexp t :width 78 :position left :stick t :noselect nil :dedicated nil)\n        popwin:special-display-config))\n\n;; Example: Always display in a side window on the right\n(defun my-claude-display-right (buffer)\n  \"Display Claude buffer in right side window.\"\n  (display-buffer buffer '((display-buffer-in-side-window)\n                           (side . right)\n                           (window-width . 90))))\n(setq claude-code-display-window-fn #'my-claude-display-right)\n```\n\n#### Using display-buffer-alist\n\nYou can also control how the Claude Code window appears using Emacs' `display-buffer-alist`. For example, to make the Claude window appear in a persistent side window on the right side of your screen that is 90 characters wide:\n\n```elisp\n(add-to-list 'display-buffer-alist\n                 '(\"^\\\\*claude\"\n                   (display-buffer-in-side-window)\n                   (side . right)\n                   (window-width . 90)))\n```\n\nThis layout works best on wide screens.\n\n### Font Setup\n\nClaude Code uses a lot of special unicode characters, and most common programming fonts don't include them all. To ensure that Claude renders special characters correctly in Emacs, you need to either use a font with really good unicode support, or set up fallback fonts for Emacs to use when your preferred font does not have a character. \n\n### Using System Fonts as Fallbacks\n\nIf you don't want to install any new fonts, you can use fonts already on your system as fallbacks. Here's a good setup for macOS, assuming your default, preferred font is \"Maple Mono\".  Substitute \"Maple Mono\" with whatever your default font is, and add this to your `init.el` file:\n\n```elisp\n;; important - tell emacs to use our fontset settings\n(setq use-default-font-for-symbols nil)\n\n;; add least preferred fonts first, most preferred last\n(set-fontset-font t 'symbol \"STIX Two Math\" nil 'prepend)\n(set-fontset-font t 'symbol \"Zapf Dingbats\" nil 'prepend)\n(set-fontset-font t 'symbol \"Menlo\" nil 'prepend)\n\n;; add your default, preferred font last\n(set-fontset-font t 'symbol \"Maple Mono\" nil 'prepend)\n```\n\nThe configuration on Linux or Windows will depend on the fonts available on your system. To test if\nyour system has a certain font, evaluate this expression:\n\n```elisp\n(find-font (font-spec :family \"DejaVu Sans Mono\"))\n```\n\nOn Linux it might look like this:\n\n```elisp\n(setq use-default-font-for-symbols nil)\n(set-fontset-font t 'symbol \"DejaVu Sans Mono\" nil 'prepend)\n\n;; your preferred, default font:\n(set-fontset-font t 'symbol \"Maple Mono\" nil 'prepend)\n```\n\n### Using JuliaMono as Fallback\n\nA cross-platform approach is to install a fixed-width font with really good unicode symbols support. \n[JuliaMono](https:\u002F\u002Fjuliamono.netlify.app\u002F) has excellent Unicode symbols support. To let the Claude Code buffer use Julia Mono for rendering Unicode characters while still using your default font for ASCII characters add this elisp code:\n\n```elisp\n(setq use-default-font-for-symbols nil)\n(set-fontset-font t 'unicode (font-spec :family \"JuliaMono\"))\n\n;; your preferred, default font:\n(set-fontset-font t 'symbol \"Maple Mono\" nil 'prepend)\n```\n\n### Using a Custom Claude Code Font\n\nIf instead you want to use a particular font just for the Claude Code REPL but use a different font\neverywhere else you can customize the `claude-code-repl-face`:\n\n```elisp\n(custom-set-faces\n   '(claude-code-repl-face ((t (:family \"JuliaMono\")))))\n```\n\n(If you set the Claude Code font to \"JuliaMono\", you can skip all the fontset fallback configurations above.)\n\n### Reducing Flickering on Window Configuration Changes\n\nTo reduce flickering in the Claude buffer on window configuration changes, you can adjust eat latency variables in a hook. This reduces flickering at the cost of some increased latency:\n\n```elisp\n  ;; reduce flickering\n  (add-hook 'claude-code-start-hook\n            (lambda ()\n              (setq-local eat-minimum-latency 0.033\n                          eat-maximum-latency 0.1)))\n```\n\n*Note*: Recent changes to claude-code.el have fixed flickering issues, making customization of these latency values less necessary. \n\n### Fixing Spaces Between Vertical Bars\n\nIf you see spaces between vertical bars in Claude's output, you can fix this by adjusting the `line-spacing` value. For example:\n\n```elisp\n;; Set line spacing to reduce gaps between vertical bars\n(setq line-spacing 0.1)\n```\n\nOr to apply it only to Claude buffers:\n\n```elisp\n(add-hook 'claude-code-start-hook\n          (lambda ()\n            ;; Reduce line spacing to fix vertical bar gaps\n            (setq-local line-spacing 0.1))) \n```\n\n## Demo\n\n### GIF Demo\n\n![Claude Code Emacs Demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fstevemolitor_claude-code.el_readme_30ab8ec413a6.gif)\n\nThis [demo](.\u002Fdemo.gif) shows claude-code.el in action, including accessing the transient menu, sending commands with file context, and fixing errors.\n\n### Video Demo\n\n[![The Emacs Claude Code Package](https:\u002F\u002Fimg.youtube.com\u002Fvi\u002FK8sCVLmFyyU\u002F0.jpg)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=K8sCVLmFyyU)\n\nCheck out this [video demo](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=K8sCVLmFyyU) demonstrating the claude-code.el package. This video was kindly created and shared by a user of the package.\n\n### Eat-specific Customization\n\nWhen using the eat terminal backend, there are additional customization options available:\n\n```elisp\n;; Customize cursor type in read-only mode (default is '(box nil nil))\n;; The format is (CURSOR-ON BLINKING-FREQUENCY CURSOR-OFF)\n;; Cursor type options: 'box, 'hollow, 'bar, 'hbar, or nil\n(setq claude-code-eat-read-only-mode-cursor-type '(bar nil nil))\n\n;; Control eat scrollback size for longer conversations\n;; The default is 131072 characters, which is usually sufficient\n;; For very long Claude sessions, you may want to increase it\n;; WARNING: Setting to nil (unlimited) is NOT recommended with Claude Code\n;; as it can cause severe performance issues with long sessions\n(setq eat-term-scrollback-size 500000)  ; Increase to 500k characters\n```\n\n### Vterm-specific Customization\n\nWhen using the vterm terminal backend, there are additional customization options available:\n\n```elisp\n;; Enable\u002Fdisable buffering to prevent flickering on multi-line input (default is t)\n;; When enabled, vterm output that appears to be redrawing multi-line input boxes\n;; will be buffered briefly and processed in a single batch\n;; This prevents flickering when Claude redraws its input box as it expands\n(setq claude-code-vterm-buffer-multiline-output t)\n\n;; Control the delay before processing buffered vterm output (default is 0.01)\n;; This is the time in seconds that vterm waits to collect output bursts\n;; A longer delay may reduce flickering more but could feel less responsive\n;; The default of 0.01 seconds (10ms) provides a good balance\n(setq claude-code-vterm-multiline-delay 0.01)\n```\n\n#### Vterm Scrollback Configuration\n\nVterm has its own scrollback limit that is separate from claude-code.el settings. By default, vterm limits scrollback to 1000 lines. To allow scrolling back to the top of long Claude conversations, you can increase `vterm-max-scrollback`:\n\n```elisp\n;; Increase vterm scrollback to 100000 lines (the maximum allowed)\n;; Note: This increases memory usage\n(setq vterm-max-scrollback 100000)\n```\n\nIf you prefer not to set this globally, you can set it only for Claude buffers using a hook:\n\n```elisp\n(add-hook 'claude-code-start-hook\n          (lambda ()\n            ;; Only increase scrollback for vterm backend\n            (when (eq claude-code-terminal-backend 'vterm)\n              (setq-local vterm-max-scrollback 100000))))\n```\n\nThis ensures that only Claude buffers have increased scrollback, while other vterm buffers maintain the default limit.\n\n#### Vterm Window Width Configuration\n\nVterm has a minimum window width setting that affects how text wraps. By default, `vterm-min-window-width` is set to 80 columns. If you resize the Claude window to be narrower than this limit, the Claude input box may wrap incorrectly, causing display issues.\n\nIf you prefer to use Claude in a narrow window (for example, in a side window), you can adjust `vterm-min-window-width`. Note that this must be set as a custom variable, either via `custom-set-variables` or `setop`, `setq` won't work:\n\n```elisp\n;; Allow vterm windows to be as narrow as 40 columns\n(setopt vterm-min-window-width 40)\n```\n\nThis is particularly useful if you like to keep Claude in a narrow side window while coding in your main window.\n\n#### Vterm Timer Delay\n\nThe `vterm-timer-delay` variable controls how often vterm refreshes its buffer when receiving data. This delay (in seconds) helps manage performance when processing large amounts of output. Setting it to `nil` disables the delay entirely.\n\nThe default value of `0.1` seconds works well with Claude Code. Since Claude often sends large bursts of data when generating code or explanations, reducing this delay or disabling it (`nil`) can significantly degrade performance. Stick with the default, or use a slightly higher value  unless you experience specific display issues. \n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the LICENSE file for details.\n","# claude-code.el\n\n一个用于 [Claude Code CLI](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code) 的 Emacs 界面，提供 Emacs 与 Claude AI 之间的集成，以实现编码辅助。\n\n## 特性\n\n- **无缝的 Emacs 集成**：无需离开 Emacs 即可启动、管理并与 Claude 交互\n- **保持在当前缓冲区**：在不分散注意力的情况下，将代码、区域或命令发送给 Claude\n- **即时修复错误**：指向 flycheck\u002Fflymake 报告的错误，并请求 Claude 进行修复\n- **多实例支持**：为不同项目或任务运行独立的 Claude 会话\n- **快速响应**：通过按键（\u003Creturn>\u002F\u003Cescape>\u002F1\u002F2\u002F3）直接回复 Claude，无需切换缓冲区\n- **智能上下文**：可选地在向 Claude 发送命令时包含文件路径和行号\n- **瞬态菜单**：通过瞬态菜单访问所有命令和斜杠命令\n- **继续对话**：恢复之前的会话或回溯到之前的某个点\n- **只读模式**：切换到只读模式后，仍可使用常规的 Emacs 命令和快捷键选择并复制文本\n- **模式循环切换**：在默认模式、自动接受修改模式和计划模式之间快速切换\n- **桌面通知**：当 Claude 完成处理时收到通知\n- **终端选择**：兼容 eat 和 vterm 后端\n- **完全可定制**：自定义快捷键、通知和显示偏好设置\n\n## 安装\n\n### 先决条件\n\n- Emacs 30.0 或更高版本\n- 已安装并配置好 [Claude Code CLI](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code)\n- 必需：transient (0.7.5+) inheritenv (0.2)\n- 可选：eat (0.9.2+) 用于 eat 后端，vterm 用于 vterm 后端\n  - 注意：如果未使用 `:vc` 安装方式，`eat` 包需要 NonGNU ELPA：\n    ```elisp\n    (add-to-list 'package-archives '(\"nongnu\" . \"https:\u002F\u002Felpa.nongnu.org\u002Fnongnu\u002F\"))\n    ```\n- 可选但推荐：[Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) 用于 IDE 集成\n\n### 使用内置 use-package（Emacs 30+）\n\n```elisp\n;; 将 melpa 添加到包源中，因为 vterm 在 melpa 上：\n(require 'package)\n(add-to-list 'package-archives '(\"melpa\" . \"https:\u002F\u002Fmelpa.org\u002Fpackages\u002F\") t)\n(package-initialize)\n\n;; 安装必需的 inheritenv 依赖：\n(use-package inheritenv\n  :vc (:url \"https:\u002F\u002Fgithub.com\u002Fpurcell\u002Finheritenv\" :rev :newest))\n\n;; 对于 eat 终端后端：\n(use-package eat :ensure t)\n\n;; 对于 vterm 终端后端：\n(use-package vterm :ensure t)\n\n;; 安装 claude-code.el\n(use-package claude-code :ensure t\n  :vc (:url \"https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\" :rev :newest)\n  :config\n  ;; 可选的 IDE 集成，使用 Monet\n  (add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n  (monet-mode 1)\n\n  (claude-code-mode)\n  :bind-keymap (\"C-c c\" . claude-code-command-map)\n\n  ;; 可选地定义重复映射，以便在调用 claude-code-cycle-mode \u002F C-c M 后，“M”键可以循环切换 Claude 的自动接受\u002F计划\u002F确认模式。\n  :bind\n  (:repeat-map my-claude-code-map (\"M\" . claude-code-cycle-mode)))\n```\n\n### 使用 straight.el\n\n```elisp\n;; 安装必需的 inheritenv 依赖：\n(use-package inheritenv\n  :straight (:type git :host github :repo \"purcell\u002Finheritenv\"))\n\n;; 对于 eat 终端后端：\n(use-package eat\n  :straight (:type git\n                   :host codeberg\n                   :repo \"akib\u002Femacs-eat\"\n                   :files (\"*.el\" (\"term\" \"term\u002F*.el\") \"*.texi\"\n                           \"*.ti\" (\"terminfo\u002Fe\" \"terminfo\u002Fe\u002F*\")\n                           (\"terminfo\u002F65\" \"terminfo\u002F65\u002F*\")\n                           (\"integration\" \"integration\u002F*\")\n                           (:exclude \".dir-locals.el\" \"*-tests.el\"))))\n\n;; 对于 vterm 终端后端：\n(use-package vterm :straight t)\n\n;; 安装 claude-code.el，使用 :depth 1 以减少下载大小：\n(use-package claude-code\n  :straight (:type git :host github :repo \"stevemolitor\u002Fclaude-code.el\" :branch \"main\" :depth 1\n                   :files (\"*.el\" (:exclude \"images\u002F*\")))\n  :bind-keymap\n  (\"C-c c\" . claude-code-command-map) ;; 或您喜欢的键\n  ;; 可选地定义重复映射，以便在调用 claude-code-cycle-mode \u002F C-c M 后，“M”键可以循环切换 Claude 的自动接受\u002F计划\u002F确认模式。\n  :bind\n  (:repeat-map my-claude-code-map (\"M\" . claude-code-cycle-mode))\n  :config\n  ;; 可选的 IDE 集成，使用 Monet\n  (add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n  (monet-mode 1)\n\n  (claude-code-mode))\n```\n\n## 基本使用\n\n### 设置前缀键\n您需要按照 [安装](#installation) 部分的说明，为 Claude Code 命令映射设置您自己的快捷键。本 README 中的示例使用 `C-c c` 作为前缀键。\n\n### 选择 eat 或 vterm\n默认情况下，claude-code.el 使用 `eat` 后端。如果您更喜欢 vterm，请自定义\n`claude-code-terminal-backend`：\n\n```elisp\n(setq claude-code-terminal-backend 'vterm)\n```\n\n### 瞬态菜单\n您可以通过调用瞬态菜单 `claude-code-transient` (`C-c c m`) 来查看重要命令列表：\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fstevemolitor_claude-code.el_readme_e35ecc0a0583.png)\n\n### 启动和停止 Claude\n要启动 Claude，请运行 `claude-code` (`C-c c c`)。这将在缓冲区文件所在项目的根目录下启动一个新的 Claude 实例；如果不在任何项目中，则会在当前目录下启动。Claude-code.el 使用 Emacs 内置的\n[project.el](https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Femacs\u002Fmanual\u002Fhtml_node\u002Femacs\u002FProjects.html)，它适用于大多数版本控制系统。\n\n要在特定目录下启动 Claude，请使用 `claude-code-start-in-directory` (`C-c c d`)。系统会提示您输入目录。\n\n`claude-code-continue` 命令将继续之前的对话，而 `claude-code-resume` 允许您从之前的会话列表中进行选择。\n\n要终止 Claude 进程并关闭其窗口，请使用 `claude-code-kill` (`C-c c k`)。\n\n### 向 Claude 发送命令\n\nClaude 启动后，您可以切换到 Claude 缓冲区并开始输入提示。或者，您也可以通过 `claude-code-send-command`（`C-c c s`）使用 minibuffer 向 Claude 发送提示。`claude-code-send-command-with-context`（`C-c c x`）还会将当前文件名和行号发送给 Claude。这在询问“这段代码是做什么的？”或“修复这段代码中的错误”时非常有用。\n\n使用 `claude-code-send-region`（`C-c c r`）命令可以将选中的区域发送给 Claude；如果没有选择区域，则会发送整个缓冲区。此命令适用于在普通 Emacs 缓冲区中编写提示并将其发送给 Claude 的场景。如果使用单个前缀参数（`C-u C-c c r`），它会在发送区域之前提示您提供额外的上下文信息。\n\n您还可以直接将文件发送给 Claude，使用 `claude-code-send-file` 按路径发送任意文件，或使用 `claude-code-send-buffer-file`（`C-c c o`）发送与当前缓冲区关联的文件。`claude-code-send-buffer-file` 命令支持与 `claude-code-send-region` 类似的前缀参数——使用单个前缀参数时会提示您输入说明，而使用双前缀参数时还会切换到 Claude 缓冲区。\n\n如果您将光标置于 flymake 或 flycheck 错误上，可以通过 `claude-code-fix-error-at-point`（`C-c c e`）请求 Claude 修复该错误。\n\n要显示或隐藏 Claude 缓冲区，请使用 `claude-code-toggle`（`C-c c t`）。要跳转到 Claude 缓冲区，请使用 `claude-code-switch-to-buffer`（`C-c c b`）。如果缓冲区处于隐藏状态，此命令会将其打开。\n\n### 管理 Claude 窗口\n\n`claude-code-toggle`（`C-c c t`）用于显示或隐藏 Claude 窗口。即使窗口被隐藏，您也可以使用 `claude-code-switch-to-buffer`（`C-c c b`）命令切换到 Claude 窗口。\n\n要在 Claude 缓冲区进入只读模式，请使用 `claude-code-toggle-read-only-mode`（`C-c c z`）。在此模式下，您可以选择和复制文本，并使用常规的 Emacs 键绑定。再次调用 `claude-code-toggle-read-only-mode` 即可退出只读模式。\n\n### 快速回复\n\n有时您希望在不切换到 Claude 缓冲区的情况下快速回复 Claude。以下命令允许您在不离开当前编辑缓冲区的情况下回答 Claude 的问题：\n\n- `claude-code-send-return`（`C-c c y`）：向 Claude 发送回车键，通常用于对 Claude 的问题回答“是”。\n- `claude-code-send-escape`（`C-c c n`）：向 Claude 发送 Esc 键，表示“否”或取消正在执行的 Claude 操作。\n- `claude-code-send-1`（`C-c c 1`）：向 Claude 发送数字“1”，以响应 Claude 查询并选择选项“1”。\n- `claude-code-send-2`（`C-c c 2`）：向 Claude 发送数字“2”。\n- `claude-code-send-3`（`C-c c 3`）：向 Claude 发送数字“3”。\n\n## 使用 [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) 进行 IDE 集成\n\n您可以选择使用 [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) 进行 IDE 集成。要将 Monet 与 Claude 集成，请执行以下操作（或使用上述等效的 `use-package` 声明）：\n\n```elisp\n(add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n(monet-mode 1)\n```\n\n当 Claude 启动新实例时，它会自动启动一个 Monet WebSocket 服务器，用于监听并发送 IDE 注释到 Claude 或从 Claude 接收注释。当前选中的内容会自动发送给 Claude，Claude 会在 Emacs 中显示差异、使用 Emacs Monet 工具打开文件、获取诊断信息等。更多详细信息请参阅 [Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet) 的文档。\n\n## 多个 Claude 实例的使用\n\n`claude-code.el` 支持在不同项目和目录中运行多个 Claude 实例。每个 Claude 实例都与特定的目录相关联（项目根目录、文件所在目录或当前目录）。\n\n#### 实例管理\n\n- 当您使用 `claude-code` 启动 Claude 时，它会为当前目录创建一个实例。\n- 如果该目录已经存在 Claude 实例，系统会提示您为新实例命名（例如，“tests”、“docs”）。\n- 您也可以使用 `claude-code-new-instance` 显式创建具有自定义名称的新实例。\n- 缓冲区名称遵循以下格式：\n  - `*claude:\u002Fpath\u002Fto\u002Fdirectory:instance-name*`（例如，`*claude:\u002Fhome\u002Fuser\u002Fproject:tests*`）。\n- 如果您所在的目录没有 Claude 实例，但其他目录中已有实例运行，系统会提示您选择一个实例。\n- 系统会记住您对该目录的选择，因此后续不会再提示您。\n\n### 实例选择\n\n针对某个实例的操作命令（如 `claude-send-command`、`claude-code-switch-to-buffer`、`claude-code-kill` 等）会在当前缓冲区所属项目有多个 Claude 实例时提示您选择要使用的实例。\n\n如果缓冲区文件未与任何正在运行的 Claude 实例关联，您可以选择其他项目中正在运行的实例。这在您希望 Claude 分析依赖项目或位于兄弟目录中的文件时非常有用。\n\nClaude-code.el 会记住哪些缓冲区与哪些 Claude 实例相关联，因此您不会反复收到提示。这种关联也有助于 Claude-code.el 在终止 Claude 进程并删除其关联缓冲区时做出正确的处理。\n\n### 每个目录的多个实例\n\n您可以为同一目录运行多个 Claude 实例，以支持不同的工作流程：\n\n- 目录中的第一个实例是“默认”实例。\n- 其他实例在创建时需要命名（例如，“tests”、“docs”、“refactor”）。\n- 当一个目录存在多个实例时，与 Claude 交互的命令会提示您选择要使用的实例。\n- 使用 `C-u claude-code-switch-to-buffer` 可以查看所有目录中的所有 Claude 实例（而不仅仅是当前目录）。\n- 使用 `claude-code-select-buffer` 作为专用命令，始终显示所有目录中的所有 Claude 实例。\n\n这样，您可以在同一个项目中为工作的不同方面进行独立的 Claude 对话，例如一个实例用于编写代码，另一个实例用于编写测试。\n\n## 在 Claude 缓冲区中工作\n\nClaude-code.el 旨在支持在 Emacs 中使用 minibuffer 和常规 Emacs 缓冲区来操作 Claude Code，同时保持正常的键绑定和完整的 Emacs 编辑功能。然而，Claude-code.el 还为在 Claude Code 终端缓冲区中工作添加了一些便利功能：\n\n您可以按 `C-g` 作为 Esc 键的替代。此外，Claude-code.el 还支持多种在 Claude Code 会话中输入换行的方式：\n\n- **默认（Shift+Return 插入换行）**：按 `Shift+Return` 插入换行，按 `Return` 发送消息。\n- **Alt+Return 风格**：按 `Alt+Return` 插入换行，按 `Return` 发送。\n- **Shift+Return 发送**：按 `Return` 插入换行，按 `Shift+Return` 发送。\n- **Super+Return 发送**：按 `Return` 插入换行，按 `Command+Return`（macOS）发送。\n\n您可以通过自定义 `claude-code-newline-keybinding-style` 来更改此行为（参见[自定义](#customization)部分）。\n\n### 命令参考\n\n- `claude-code-transient` (`C-c c m`) - 显示所有命令（瞬态菜单）\n- `claude-code` (`C-c c c`) - 启动 Claude。使用前缀参数 (`C-u`) 时，创建后会切换到 Claude 缓冲区。使用双重前缀 (`C-u C-u`) 时，会提示输入项目目录。\n- `claude-code-start-in-directory` (`C-c c d`) - 提示输入目录并在该目录下启动 Claude。使用前缀参数 (`C-u`) 时，创建后会切换到 Claude 缓冲区。\n- `claude-code-continue` (`C-c c C`) - 启动 Claude 并继续之前的对话。使用前缀参数 (`C-u`) 时，创建后会切换到 Claude 缓冲区。使用双重前缀 (`C-u C-u`) 时，会提示输入项目目录。\n- `claude-code-resume` (`C-c c R`) - 从交互式列表中恢复特定的 Claude 会话。使用前缀参数 (`C-u`) 时，创建后会切换到 Claude 缓冲区。使用双重前缀 (`C-u C-u`) 时，会提示输入项目目录。\n- `claude-code-new-instance` (`C-c c i`) - 创建具有自定义名称的新 Claude 实例。始终提示输入实例名称，而 `claude-code` 在没有实例存在时会使用“default”。使用前缀参数 (`C-u`) 时，创建后会切换到 Claude 缓冲区。使用双重前缀 (`C-u C-u`) 时，会提示输入项目目录。\n- `claude-code-kill` (`C-c c k`) - 杀死当前的 Claude 会话。\n- `claude-code-kill-all` (`C-c c K`) - 杀死所有目录下的所有 Claude 实例。\n- `claude-code-send-command` (`C-c c s`) - 向 Claude 发送命令。使用前缀参数 (`C-u`) 时，发送后会切换到 Claude 缓冲区。\n- `claude-code-send-command-with-context` (`C-c c x`) - 带有当前文件和行上下文的命令发送。使用前缀参数 (`C-u`) 时，发送后会切换到 Claude 缓冲区。\n- `claude-code-send-region` (`C-c c r`) - 将当前区域或缓冲区发送给 Claude。使用前缀参数 (`C-u`) 时，会提示添加到文本中的指令。使用双重前缀 (`C-u C-u`) 时，会添加指令并切换到 Claude 缓冲区。\n- `claude-code-send-file` - 将指定文件发送给 Claude。会提示输入文件路径。\n- `claude-code-send-buffer-file` (`C-c c o`) - 将当前缓冲区关联的文件发送给 Claude。使用前缀参数 (`C-u`) 时，会提示添加到文件中的指令。使用双重前缀 (`C-u C-u`) 时，会添加指令并切换到 Claude 缓冲区。\n- `claude-code-fix-error-at-point` (`C-c c e`) - 请求 Claude 修复当前光标位置的错误（适用于 flycheck、flymake 及任何实现 help-at-pt 的系统）。使用前缀参数 (`C-u`) 时，发送后会切换到 Claude 缓冲区。\n- `claude-code-fork` (`C-c c f`) - 分叉对话（通过向 Claude 发送 escape-escape 跳转到之前的对话）。\n- `claude-code-slash-commands` (`C-c c \u002F`) - 访问 Claude 斜杠命令菜单。\n- `claude-code-toggle` (`C-c c t`) - 切换 Claude 窗口的显示状态。\n- `claude-code-switch-to-buffer` (`C-c c b`) - 切换到 Claude 缓冲区。使用前缀参数 (`C-u`) 时，会显示所有目录下的所有 Claude 实例。\n- `claude-code-select-buffer` (`C-c c B`) - 从所有项目和目录下的运行实例中选择并切换到一个 Claude 缓冲区。\n- `claude-code-toggle-read-only-mode` (`C-c c z`) - 在 Claude 缓冲区中切换只读模式与正常模式（便于选择和复制文本）。\n- `claude-code-cycle-mode` (`C-c c M`) - 向 Claude 发送 Shift-Tab，以在默认模式、自动接受编辑模式和计划模式之间循环切换。请参阅上方的安装部分，配置重复映射，以便在首次调用后使用 “M” 键即可循环切换模式。\n\n- `claude-code-send-return` (`C-c c y`) - 向 Claude 发送回车键（用于在不切换到 Claude REPL 缓冲区的情况下确认操作，例如对 Claude 的“是”做出回应）。\n- `claude-code-send-escape` (`C-c c n`) - 向 Claude 发送 Esc 键（用于在 Claude 请求确认时说“否”，且无需切换到 Claude REPL 缓冲区）。\n- `claude-code-send-1` (`C-c c 1`) - 向 Claude 发送数字“1”（用于在 Claude 提供编号菜单时选择第一个选项）。\n- `claude-code-send-2` (`C-c c 2`) - 向 Claude 发送数字“2”（用于在 Claude 提供编号菜单时选择第二个选项）。\n- `claude-code-send-3` (`C-c c 3`) - 向 Claude 发送数字“3”（用于在 Claude 提供编号菜单时选择第三个选项）。\n\n## 桌面通知\n\nclaude-code.el 会在 Claude 完成处理并等待输入时通知您。默认情况下，它会在 minibuffer 中显示消息，并使 modeline 脉动以提供视觉反馈。\n\n### macOS 原生通知\n\n若要使用带有声音的 macOS 原生通知，请在您的配置中添加以下内容：\n\n```elisp\n(defun my-claude-notify (title message)\n  \"显示带有声音的 macOS 通知。\"\n  (call-process \"osascript\" nil nil nil\n                \"-e\" (format \"display notification \\\"%s\\\" with title \\\"%s\\\" sound name \\\"Glass\\\"\"\n                             message title)))\n\n(setq claude-code-notification-function #'my-claude-notify)\n```\n\n这将在 Claude 准备就绪时显示带有“Glass”音效的系统通知。您可以将音效名称更改为任何系统音效（如“Ping”、“Hero”、“Morse”等），或移除 `sound name` 部分以获得无声通知。\n\n### Linux 原生通知\n\n对于 Linux 桌面通知，您可以使用 `notify-send`（GNOME\u002FUnity）或 `kdialog`（KDE）：\n\n```elisp\n;; 对于 GNOME\u002FUnity 桌面\n(defun my-claude-notify (title message)\n  \"使用 notify-send 显示 Linux 通知。\"\n  (if (executable-find \"notify-send\")\n      (call-process \"notify-send\" nil nil nil title message)\n    (message \"%s: %s\" title message)))\n\n(setq claude-code-notification-function #'my-claude-notify)\n```\n\n要在 Linux 上添加声音：\n\n```elisp\n(defun my-claude-notify-with-sound (title message)\n  \"显示带有声音的 Linux 通知。\"\n  (when (executable-find \"notify-send\")\n    (call-process \"notify-send\" nil nil nil title message))\n  ;; 如果 paplay 可用，则播放声音\n  (when (executable-find \"paplay\")\n    (call-process \"paplay\" nil nil nil \"\u002Fusr\u002Fshare\u002Fsounds\u002Ffreedesktop\u002Fstereo\u002Fmessage.oga\")))\n\n(setq claude-code-notification-function #'my-claude-notify-with-sound)\n```\n\n### Windows 原生通知\n\n在 Windows 上，你可以使用 PowerShell 创建 Toast 通知：\n\n```elisp\n(defun my-claude-notify (title message)\n  \"使用 PowerShell 显示 Windows 通知。\"\n  (call-process \"powershell\" nil nil nil\n                \"-NoProfile\" \"-Command\"\n                (concat \"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null; \"\n                        \"$template = '\u003Ctoast>\u003Cvisual>\u003Cbinding template=\\\"ToastGeneric\\\">\u003Ctext>\" title \"\u003C\u002Ftext>\u003Ctext>\" message \"\u003C\u002Ftext>\u003C\u002Fbinding>\u003C\u002Fvisual>\u003C\u002Ftoast>'; \"\n                        \"$xml = New-Object Windows.Data.Xml.Dom.XmlDocument; \"\n                        \"$xml.LoadXml($template); \"\n                        \"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml); \"\n                        \"[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('Emacs').Show($toast)\")))\n\n(setq claude-code-notification-function #'my-claude-notify)\n```\n\n*注意：Linux 和 Windows 的示例尚未经过测试。欢迎提供反馈和改进！*\n\n### Claude Code 钩子集成\n\n`claude-code.el` 提供了通过 `emacsclient` 从 Claude Code CLI 接收钩子事件的功能。\n\n有关钩子监听器和设置函数的全面示例，请参阅 [`examples\u002Fhooks\u002Fclaude-code-hook-examples.el`](examples\u002Fhooks\u002Fclaude-code-hook-examples.el)。\n\n#### 钩子 API\n\n- `claude-code-event-hook` - 当 Claude Code CLI 触发事件时运行的 Emacs 钩子\n- `claude-code-handle-hook` - 所有 Claude Code CLI 钩子的 **统一入口点**。请在你的 CLI 钩子中使用 `(type buffer-name &rest args)` 调用此函数，并将 JSON 数据作为 `emacsclient` 的额外参数传递。\n\n#### JSON 响应系统\n\n钩子可以返回结构化的 JSON 数据，以使用 `run-hook-with-args-until-success` 控制 Claude Code 的行为：\n\n1. **多个处理程序**：在 `claude-code-event-hook` 上注册多个函数\n2. **顺序执行**：函数按顺序调用，并传递消息数据\n3. **首个响应获胜**：当某个函数返回非空 JSON 时，执行停止\n4. **双向通信**：JSON 响应会发送回 Claude Code CLI\n\n这使得交互式工作流成为可能，例如权限提示，其中钩子可以影响 Claude 的行为。\n\n#### 设置步骤\n\n1. **将 bin 目录添加到 PATH 中**（这是钩子包装脚本所必需的）：\n   ```bash\n   export PATH=\"\u002Fpath\u002Fto\u002Fclaude-code.el\u002Fbin:$PATH\"\n   ```\n   请将其添加到你的 Bash 配置文件（如 `~\u002F.bashrc`、`~\u002F.bash_profile` 等），因为 Claude Code 需要在 Bash 环境中访问该路径。\n\n2. **启动 Emacs 服务器**，以便 `emacsclient` 可以与你的 Emacs 实例通信：\n   ```elisp\n   ;; 启动 Emacs 服务器（添加到你的 init.el 文件中）\n   (start-server)\n\n   ;; 使用标准 Emacs 函数添加你的钩子监听器\n   (add-hook 'claude-code-event-hook 'my-claude-hook-listener)\n   ```\n\n#### 自定义钩子监听器\n\n钩子监听器会接收到一个包含以下键的消息 plist：\n- `:type` - 钩子类型（例如 `'notification`、`'stop`、`'pre-tool-use`、`'post-tool-use`）\n- `:buffer-name` - 来自 `$CLAUDE_BUFFER_NAME` 的 Claude 缓冲区名称\n- `:json-data` - 来自 Claude CLI 的 JSON 负载\n- `:args` - 额外参数列表（在使用扩展配置时）\n\n```elisp\n;; 定义你自己的钩子监听器函数\n(defun my-claude-hook-listener (message)\n  \"Claude Code 钩子的自定义监听器。\nMESSAGE 是一个包含 :type、:buffer-name、:json-data 和 :args 键的 plist。\"\n  (let ((hook-type (plist-get message :type))\n        (buffer-name (plist-get message :buffer-name))\n        (json-data (plist-get message :json-data))\n        (args (plist-get message :args)))\n    (cond \n     ((eq hook-type 'notification)\n      (message \"Claude 已就绪于 %s！JSON：%s\" buffer-name json-data))\n     ((eq hook-type 'stop)  \n      (message \"Claude 已完成于 %s！JSON：%s\" buffer-name json-data))\n     (t\n      (message \"Claude 钩子：%s，附带 JSON：%s\" hook-type json-data)))))\n\n;; 使用标准 Emacs 钩子函数添加钩子监听器\n(add-hook 'claude-code-event-hook 'my-claude-hook-listener)\n```\n\n完整的监听器示例可在示例文件中找到，展示了通知、日志记录、Org 模式集成以及如何使用 `:args` 字段中的额外参数。\n\n#### Claude Code CLI 配置\n\n配置 Claude Code CLI 钩子，使其通过 `emacsclient` 调用 `claude-code-handle-hook`，并将 JSON 数据作为附加参数传递：\n\n```json\n{\n  \"hooks\": {\n    \"Notification\": [\n      {\n        \"matcher\": \"\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"emacsclient --eval \\\"(claude-code-handle-hook 'notification \\\\\\\"$CLAUDE_BUFFER_NAME\\\\\\\")\\\" \\\"$(cat)\\\"\"\n          }\n        ]\n      }\n    ],\n    \"Stop\": [\n      {\n        \"matcher\": \"\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"emacsclient --eval \\\"(claude-code-handle-hook 'stop \\\\\\\"$CLAUDE_BUFFER_NAME\\\\\\\")\\\" \\\"$(cat)\\\"\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n命令模式如下：\n```bash\nemacsclient --eval \"(claude-code-handle-hook 'notification \\\"$CLAUDE_BUFFER_NAME\\\")\" \"$(cat)\" \"ARG1\" \"ARG2\" \"ARG3\"\n```\n\n其中：\n- `\"$(cat)\"` - 来自标准输入的 JSON 数据（始终必需）\n- `ARG1` 是 `\"$PWD\"` - 当前工作目录\n- `ARG2` 是 `\"$(date -Iseconds)\"` - 时间戳\n- `ARG3` 是 `\"$$\"` - 进程 ID\n\n`claude-code-handle-hook` 会创建一个发送给监听器的消息 plist：\n```elisp\n(list :type 'notification \n      :buffer-name \"$CLAUDE_BUFFER_NAME\"\n      :json-data \"$(cat)\" \n      :args '(\"ARG1\" \"ARG2\" \"ARG3\"))\n```\n\n有关 CLI 钩子设置的详细信息，请参阅 [Claude Code 钩子文档](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fhooks)。\n\n## 小贴士与技巧\n\n- **粘贴图片**：使用 `C-v` 将图片粘贴到 Claude 窗口中。请注意，在 macOS 上，应使用 `Control-v` 而不是 `Command-v`。\n- **粘贴文本**：使用 `C-y`（即 `yank`）将文本粘贴到 Claude 窗口中。\n- **发送命令前保存文件**：Claude 直接从磁盘读取文件内容，而不是从 Emacs 缓冲区中读取。在发送引用文件内容的命令之前，请务必先保存文件（`C-x C-s`）。可以启用 `global-auto-revert-mode`，以便自动将 Emacs 缓冲区与 Claude 所做的文件更改同步：\n  ```elisp\n  (global-auto-revert-mode 1)\n  ;; 如果文件在 Claude 修改后无法可靠地自动重新加载，\n  ;; 可以禁用文件通知功能，改用轮询方式：\n  (setq auto-revert-use-notify nil)\n  ```\n- **通过钩子实现自动重新加载**：若需更精细地控制缓冲区的重新加载，可使用监听 Claude 文件编辑的自动重新加载钩子示例：\n  ```elisp\n  ;; 加载自动重新加载钩子\n  (load-file \"examples\u002Fhooks\u002Fclaude-code-auto-revert-hook.el\")\n  ;; 设置自动重新加载模式（任选其一）：\n  (setup-claude-auto-revert)           ; 安全模式 - 跳过已修改的缓冲区\n  (setup-claude-auto-revert-aggressive) ; 提示是否重新加载已修改的缓冲区\n  (setup-claude-auto-revert-org)       ; 对 Org 文件进行特殊处理\n  ```\n  随后，在你的 `~\u002F.claude\u002Fsettings.json` 中配置 PostToolUse 钩子（参见 `examples\u002Fhooks\u002Fauto-revert-settings.json`）。\n\n## 自定义设置\n\n```elisp\n;; 设置命令映射的快捷键。\n(global-set-key (kbd \"C-c C-a\") claude-code-command-map)\n\n;; 设置 Claude 终端模拟的终端类型（默认为 \"xterm-256color\"）。\n;; 这决定了终端的功能，例如颜色支持等。\n;; 更多信息请参阅 eat-term-name 的文档。\n(setq claude-code-term-name \"xterm-256color\")\n\n;; 更改 Claude 可执行文件的路径（默认为 \"claude\"）。\n;; 如果 Claude 不在你的 PATH 中，或你希望使用特定版本时，此设置非常有用。\n(setq claude-code-program \"\u002Fusr\u002Flocal\u002Fbin\u002Fclaude\")\n\n;; 设置 Claude 的命令行参数\n;; 例如，启用详细输出\n(setq claude-code-program-switches '(\"--verbose\"))\n\n;; 添加在 Claude 启动后运行的钩子\n(add-hook 'claude-code-start-hook 'my-claude-setup-function)\n\n;; 调整初始化延迟（默认为 0.1 秒）\n;; 这有助于防止在缓冲区显示时，Claude 尚未完全准备好而导致的终端布局问题。\n(setq claude-code-startup-delay 0.2)\n\n;; 配置缓冲区大小阈值，用于触发确认提示（默认为 100000 字符）。\n;; 如果缓冲区超过此阈值，claude-code-send-region 会在将整个缓冲区发送给 Claude 之前请求确认。\n(setq claude-code-large-buffer-threshold 100000)\n\n;; 配置在 Claude 缓冲区中输入换行和发送消息的按键绑定风格。\n;; 可选风格如下：\n;;   'newline-on-shift-return - S-return 插入换行，RET 发送消息（默认）\n;;   'newline-on-alt-return   - M-return 插入换行，RET 发送消息\n;;   'shift-return-to-send    - RET 插入换行，S-return 发送消息\n;;   'super-return-to-send    - RET 插入换行，s-return 发送消息（macOS 上为 Command+Return）\n(setq claude-code-newline-keybinding-style 'newline-on-shift-return)\n\n;; 启用或禁用 Claude 完成任务并等待输入时的通知功能（默认为 t）。\n(setq claude-code-enable-notifications t)\n\n;; 自定义通知函数（默认为 claude-code--default-notification）。\n;; 该函数应接受两个参数：标题和消息。\n;; 默认函数会显示一条消息，并使模型线闪烁以提供视觉反馈。\n(setq claude-code-notification-function 'claude-code--default-notification)\n\n;; 示例：使用自定义通知函数\n(defun my-claude-notification (title message)\n  \"Claude Code 的自定义通知函数。\"\n  ;; 在此处添加你的自定义通知逻辑\n  (message \"[%s] %s\" title message))\n(setq claude-code-notification-function 'my-claude-notification)\n\n;; 配置杀掉实例时的确认行为（默认为 t）。\n;; 当为 t 时，claude-code-kill 会在终止实例前提示确认。\n;; 当为 nil 时，直接终止 Claude 实例而不进行确认。\n(setq claude-code-confirm-kill t)\n\n;; 启用或禁用窗口大小调整优化功能（默认为 t）。\n;; 启用后，只有当窗口宽度发生变化时才会触发终端重排，\n;; 而不会因高度变化而重新绘制。这可以避免在垂直分割窗口时不必要的重绘，\n;; 从而提升性能并减少视觉瑕疵。\n;; 如果调整窗口大小后出现终端显示问题，可将其设置为 nil。\n(setq claude-code-optimize-window-resize t)\n\n;; 启用或禁用 no-delete-other-windows 参数（默认为 nil）。\n;; 启用后，Claude Code 窗口将设置 no-delete-other-windows 参数，\n;; 从而防止在执行 delete-other-windows 或类似命令时关闭 Claude 窗口，\n;; 保持 Claude 缓冲区始终可见且可访问。\n(setq claude-code-no-delete-other-windows t)\n\n;; 切换显示 Claude 缓冲区时自动选择该缓冲区（默认为 nil）。\n;; 当设置为 t 时，claude-code-toggle 在显示 Claude 缓冲区后会将焦点切换到该缓冲区。\n;; 当为 nil 时，缓冲区虽被显示，但焦点仍保留在当前缓冲区。\n(setq claude-code-toggle-auto-select t)\n```\n\n### 自定义窗口位置\n\n#### 使用 display-window 函数\n\n你可以通过设置 `claude-code-display-window-fn` 来自定义 Claude Code 窗口的显示方式。该函数接收 Claude 缓冲区作为参数，并应以适当的方式显示它：\n\n```elisp\n;; 使用带有自定义配置的 display-buffer\n(setq claude-code-display-window-fn #'display-buffer)\n\n;; 示例：使用 popwin 在侧边窗口显示\n(setq claude-code-display-window-fn #'display-buffer)\n(let ((buffer-regexp \"^\\\\*claude:.+:.+\\\\*$\"))\n  (push `(,buffer-regexp :regexp t :width 78 :position left :stick t :noselect nil :dedicated nil)\n        popwin:special-display-config))\n\n;; 示例：始终在右侧侧边窗口显示\n(defun my-claude-display-right (buffer)\n  \"将 Claude 缓冲区显示在右侧侧边窗口。\"\n  (display-buffer buffer '((display-buffer-in-side-window)\n                           (side . right)\n                           (window-width . 90))))\n(setq claude-code-display-window-fn #'my-claude-display-right)\n```\n\n#### 使用 display-buffer-alist\n\n你还可以通过 Emacs 的 `display-buffer-alist` 控制 Claude Code 窗口的显示方式。例如，让 Claude 窗口始终出现在屏幕右侧的固定侧边窗口中，窗口宽度为 90 个字符：\n\n```elisp\n(add-to-list 'display-buffer-alist\n                 '(\"^\\\\*claude\"\n                   (display-buffer-in-side-window)\n                   (side . right)\n                   (window-width . 90)))\n```\n\n这种布局最适合宽屏显示器。\n\n### 字体设置\n\nClaude Code 使用了大量的特殊 Unicode 字符，而大多数常见的编程字体并不包含所有这些字符。为了确保 Emacs 能够正确渲染 Claude 的特殊字符，你需要使用一个对 Unicode 支持非常全面的字体，或者为 Emacs 设置回退字体，以便在你首选的字体缺少某个字符时使用。\n\n### 使用系统字体作为回退\n\n如果你不想安装任何新字体，可以直接使用系统中已有的字体作为回退。以下是在 macOS 上的一个良好配置，假设你的默认首选字体是“Maple Mono”。请将“Maple Mono”替换为你实际使用的默认字体，并将其添加到你的 `init.el` 文件中：\n\n```elisp\n;; 重要：告诉 Emacs 使用我们的字体集设置\n(setq use-default-font-for-symbols nil)\n\n;; 先添加最不常用的字体，最后添加最常用的字体\n(set-fontset-font t 'symbol \"STIX Two Math\" nil 'prepend)\n(set-fontset-font t 'symbol \"Zapf Dingbats\" nil 'prepend)\n(set-fontset-font t 'symbol \"Menlo\" nil 'prepend)\n\n;; 最后添加你的默认首选字体\n(set-fontset-font t 'symbol \"Maple Mono\" nil 'prepend)\n```\n\n在 Linux 或 Windows 上的配置则取决于你系统中可用的字体。要测试你的系统是否安装了某种字体，可以评估以下表达式：\n\n```elisp\n(find-font (font-spec :family \"DejaVu Sans Mono\"))\n```\n\n在 Linux 上，配置可能如下所示：\n\n```elisp\n(setq use-default-font-for-symbols nil)\n(set-fontset-font t 'symbol \"DejaVu Sans Mono\" nil 'prepend)\n\n;; 你的首选默认字体：\n(set-fontset-font t 'symbol \"Maple Mono\" nil 'prepend)\n```\n\n### 使用 JuliaMono 作为回退\n\n一种跨平台的方法是安装一款具有出色 Unicode 符号支持的等宽字体。[JuliaMono](https:\u002F\u002Fjuliamono.netlify.app\u002F) 对 Unicode 符号的支持非常优秀。为了让 Claude Code 缓冲区在渲染 Unicode 字符时使用 Julia Mono，同时在显示 ASCII 字符时仍使用你的默认字体，可以添加以下 Elisp 代码：\n\n```elisp\n(setq use-default-font-for-symbols nil)\n(set-fontset-font t 'unicode (font-spec :family \"JuliaMono\"))\n\n;; 你的首选默认字体：\n(set-fontset-font t 'symbol \"Maple Mono\" nil 'prepend)\n```\n\n### 自定义 Claude Code 字体\n\n如果你希望仅为 Claude Code REPL 使用特定字体，而在其他地方使用不同的字体，则可以自定义 `claude-code-repl-face`：\n\n```elisp\n(custom-set-faces\n   '(claude-code-repl-face ((t (:family \"JuliaMono\")))))\n```\n\n（如果将 Claude Code 的字体设置为“JuliaMono”，则可以跳过上述所有的字体集回退配置。）\n\n### 减少窗口布局变化时的闪烁\n\n为了减少窗口布局变化时 Claude 缓冲区的闪烁，可以在钩子中调整 eat 延迟相关变量。这样做会以增加一些延迟为代价来减少闪烁：\n\n```elisp\n  ;; 减少闪烁\n  (add-hook 'claude-code-start-hook\n            (lambda ()\n              (setq-local eat-minimum-latency 0.033\n                          eat-maximum-latency 0.1)))\n```\n\n*注意*：最近对 claude-code.el 的更新已经修复了闪烁问题，因此现在对这些延迟值进行自定义的需求已经大大降低。\n\n### 修复竖线之间的空格\n\n如果在 Claude 的输出中看到竖线之间有空格，可以通过调整 `line-spacing` 值来解决。例如：\n\n```elisp\n;; 设置行间距以减少竖线之间的间隙\n(setq line-spacing 0.1)\n```\n\n或者仅针对 Claude 缓冲区应用：\n\n```elisp\n(add-hook 'claude-code-start-hook\n          (lambda ()\n            ;; 减小行间距以修复竖线间隙\n            (setq-local line-spacing 0.1))) \n```\n\n## 演示\n\n### GIF 演示\n\n![Claude Code Emacs 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fstevemolitor_claude-code.el_readme_30ab8ec413a6.gif)\n\n这个 [演示](.\u002Fdemo.gif) 展示了 claude-code.el 的实际运行效果，包括访问临时菜单、带文件上下文发送命令以及错误修复等功能。\n\n### 视频演示\n\n[![Emacs Claude Code 插件](https:\u002F\u002Fimg.youtube.com\u002Fvi\u002FK8sCVLmFyyU\u002F0.jpg)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=K8sCVLmFyyU)\n\n请观看这个 [视频演示](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=K8sCVLmFyyU)，它展示了 claude-code.el 插件的功能。该视频由一位插件用户友好地制作并分享。\n\n### eat 特定的自定义设置\n\n当使用 eat 终端后端时，还有一些额外的自定义选项可供使用：\n\n```elisp\n;; 自定义只读模式下的光标样式（默认为 '(box nil nil)）\n;; 格式为 (CURSOR-ON BLINKING-FREQUENCY CURSOR-OFF)\n;; 光标样式选项：'box, 'hollow, 'bar, 'hbar, 或 nil\n(setq claude-code-eat-read-only-mode-cursor-type '(bar nil nil))\n\n;; 控制 eat 的滚动缓冲区大小，以支持更长时间的对话\n;; 默认值为 131072 个字符，通常已足够\n;; 对于非常长的 Claude 会话，你可能需要增大此值\n;; 警告：将此值设置为 nil（无限）并不推荐用于 Claude Code，\n;; 因为这可能导致长时间会话时出现严重的性能问题。\n(setq eat-term-scrollback-size 500000)  ; 增加至 50 万个字符\n```\n\n### Vterm 特定的自定义设置\n\n当使用 vterm 终端后端时，还有一些额外的自定义选项可供使用：\n\n```elisp\n;; 启用\u002F禁用缓冲以防止多行输入时的闪烁（默认为 t）\n;; 启用后，vterm 输出中看起来像是重绘多行输入框的内容\n;; 会短暂地被缓冲，并以单批方式处理\n;; 这可以防止 Claude 在扩展其输入框时出现闪烁\n(setq claude-code-vterm-buffer-multiline-output t)\n\n;; 控制缓冲的 vterm 输出开始处理之前的延迟时间（默认为 0.01）\n;; 这是 vterm 等待收集输出突发的时间，单位为秒\n;; 延迟时间越长，闪烁现象可能会越少，但响应速度可能会变慢\n;; 默认的 0.01 秒（10 毫秒）是一个较好的平衡点\n(setq claude-code-vterm-multiline-delay 0.01)\n```\n\n#### Vterm 回滚配置\n\nVterm 有自己的回滚限制，这与 claude-code.el 的设置是分开的。默认情况下，vterm 将回滚限制为 1000 行。为了能够滚动到长时间 Claude 对话的顶部，您可以增加 `vterm-max-scrollback`：\n\n```elisp\n;; 将 vterm 回滚限制增加到 100000 行（允许的最大值）\n;; 注意：这会增加内存使用量\n(setq vterm-max-scrollback 100000)\n```\n\n如果您不想全局设置此值，也可以仅针对 Claude 缓冲区使用钩子进行设置：\n\n```elisp\n(add-hook 'claude-code-start-hook\n          (lambda ()\n            ;; 只对 vterm 后端增加回滚限制\n            (when (eq claude-code-terminal-backend 'vterm)\n              (setq-local vterm-max-scrollback 100000))))\n```\n\n这样可以确保只有 Claude 缓冲区具有更大的回滚限制，而其他 vterm 缓冲区则保持默认限制。\n\n#### Vterm 窗口宽度配置\n\nVterm 有一个最小窗口宽度设置，它会影响文本换行的方式。默认情况下，`vterm-min-window-width` 被设置为 80 列。如果您将 Claude 窗口调整得比这个限制更窄，Claude 输入框可能会错误地换行，从而导致显示问题。\n\n如果您希望在较窄的窗口中使用 Claude（例如在侧边窗口中），可以调整 `vterm-min-window-width`。请注意，这必须作为自定义变量设置，可以通过 `custom-set-variables` 或 `setopt` 来完成，`setq` 是不起作用的：\n\n```elisp\n;; 允许 vterm 窗口的宽度低至 40 列\n(setopt vterm-min-window-width 40)\n```\n\n这在您喜欢将 Claude 放在狭窄的侧边窗口中，同时在主窗口中编写代码时特别有用。\n\n#### Vterm 定时器延迟\n\n`vterm-timer-delay` 变量控制 vterm 在接收数据时刷新其缓冲区的频率。这个延迟时间（以秒为单位）有助于在处理大量输出时管理性能。将其设置为 `nil` 会完全禁用延迟。\n\n默认值 0.1 秒对于 Claude Code 来说效果很好。由于 Claude 在生成代码或解释时经常会发送大量的数据，因此降低此延迟或将其禁用（设置为 `nil`）会显著降低性能。除非您遇到特定的显示问题，否则请坚持使用默认值，或者稍微提高一点。\n\n## 贡献\n欢迎贡献！请随时提交 Pull Request。\n\n## 许可证\n本项目采用 Apache License 2.0 许可证——详情请参阅 LICENSE 文件。","# claude-code.el 快速上手指南\n\n`claude-code.el` 是一个 Emacs 插件，旨在将 [Claude Code CLI](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code) 无缝集成到 Emacs 编辑器中，让你无需离开编辑器即可与 Claude AI 进行代码协作、错误修复和对话。\n\n## 环境准备\n\n在开始之前，请确保你的开发环境满足以下要求：\n\n*   **Emacs 版本**：需要 Emacs 30.0 或更高版本。\n*   **核心依赖**：必须安装并配置好 [Claude Code CLI](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code)。\n*   **Emacs 包依赖**：\n    *   `transient` (版本 0.7.5+)\n    *   `inheritenv` (版本 0.2)\n*   **终端后端（二选一）**：\n    *   **推荐**：`eat` (版本 0.9.2+)。若通过非 `:vc` 方式安装，需添加 NonGNU ELPA 源：\n        ```elisp\n        (add-to-list 'package-archives '(\"nongnu\" . \"https:\u002F\u002Felpa.nongnu.org\u002Fnongnu\u002F\"))\n        ```\n    *   **备选**：`vterm` (需从 MELPA 安装)。\n*   **可选增强**：[Monet](https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fmonet)，用于更深层的 IDE 集成（如自动发送选中代码、显示 Diff 等）。\n\n## 安装步骤\n\n推荐使用 Emacs 30+ 内置的 `use-package` 进行安装。请将以下配置添加到你的 Emacs 配置文件（如 `init.el`）中。\n\n### 1. 配置包归档源\n确保已添加 MELPA 源（用于获取 `vterm`）：\n\n```elisp\n(require 'package)\n(add-to-list 'package-archives '(\"melpa\" . \"https:\u002F\u002Fmelpa.org\u002Fpackages\u002F\") t)\n(package-initialize)\n```\n\n### 2. 安装依赖与插件\n复制以下代码块到你的配置文件中。该配置会自动安装 `inheritenv`、终端后端以及 `claude-code.el` 本身。\n\n```elisp\n;; 安装必需依赖 inheritenv\n(use-package inheritenv\n  :vc (:url \"https:\u002F\u002Fgithub.com\u002Fpurcell\u002Finheritenv\" :rev :newest))\n\n;; 选择终端后端：推荐使用 eat\n(use-package eat :ensure t)\n;; 如果偏好 vterm，请使用下面这行代替上面那行：\n;; (use-package vterm :ensure t)\n\n;; 安装 claude-code.el\n(use-package claude-code :ensure t\n  :vc (:url \"https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\" :rev :newest)\n  :config\n  ;; 可选：启用 Monet IDE 集成\n  ;; (add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n  ;; (monet-mode 1)\n\n  (claude-code-mode)\n  :bind-keymap (\"C-c c\" . claude-code-command-map)\n\n  ;; 可选：定义重复映射，方便快速切换模式\n  :bind\n  (:repeat-map my-claude-code-map (\"M\" . claude-code-cycle-mode)))\n```\n\n> **注意**：如果你使用 `straight.el` 管理包，请参考原文 README 中的 `straight.el` 配置段落进行调整。\n\n## 基本使用\n\n安装完成后，重启 Emacs 或重新加载配置文件即可开始使用。默认前缀键为 `C-c c`。\n\n### 1. 启动 Claude\n在项目根目录或当前文件所在目录下，按下 `C-c c c` (`claude-code`) 启动一个新的 Claude 会话。\n*   若需在特定目录启动，使用 `C-c c d`。\n*   若要恢复之前的会话，使用 `C-c c` 后选择 `continue` 或 `resume`。\n\n### 2. 发送指令与代码\n你可以通过多种方式与 Claude 交互：\n\n*   **发送当前文件或区域**：\n    *   `C-c c r` (`claude-code-send-region`)：发送选中的代码区域（若无选中则发送整个缓冲区）。\n    *   `C-c c o` (`claude-code-send-buffer-file`)：发送当前文件。\n    *   `C-c c x` (`claude-code-send-command-with-context`)：发送命令并附带当前文件名和行号上下文（适合询问“这段代码做了什么”或“修复此处的 bug\"）。\n*   **直接输入命令**：\n    *   `C-c c s` (`claude-code-send-command`)：在 minibuffer 中输入提示词发送给 Claude。\n*   **快速修复错误**：\n    *   将光标移至 `flycheck` 或 `flymake` 报错处，按下 `C-c c e` (`claude-code-fix-error-at-point`) 让 Claude 自动修复。\n\n### 3. 窗口管理与交互\n*   **显示\u002F隐藏窗口**：`C-c c t` (`claude-code-toggle`)。\n*   **切换焦点**：`C-c c b` (`claude-code-switch-to-buffer`)。\n*   **只读模式**：`C-c c z`。在此模式下可使用标准 Emacs 快捷键选择和复制文本。\n*   **快速响应**：无需切换窗口即可回复 Claude 的确认请求：\n    *   `C-c c y`：发送回车（确认\u002FYes）。\n    *   `C-c c n`：发送 Esc（取消\u002FNo）。\n    *   `C-c c 1` \u002F `2` \u002F `3`：发送对应数字选项。\n\n### 4. 调用菜单\n按下 `C-c c m` (`claude-code-transient`) 可弹出完整的功能菜单，浏览所有可用命令和斜杠命令。","资深 Emacs 用户正在重构一个遗留的 Python 模块，需要频繁修复静态检查报错并生成单元测试。\n\n### 没有 claude-code.el 时\n- **上下文频繁切换**：开发者必须离开代码缓冲区，切换到终端或浏览器与 Claude 交互，复制粘贴代码片段，严重打断心流。\n- **错误修复低效**：面对 Flycheck 报出的类型错误，需手动截取错误信息和相关代码行，描述清楚位置后发送给 AI，来回沟通成本高。\n- **会话管理混乱**：同时处理多个重构任务时，难以在终端中快速区分不同项目的对话历史，容易混淆上下文。\n- **交互响应迟缓**：无法通过简单的快捷键确认 AI 的修改建议或切换“计划\u002F自动接受”模式，必须依赖鼠标或复杂的终端输入。\n\n### 使用 claude-code.el 后\n- **沉浸式编码体验**：直接在 Emacs 缓冲区选中代码区域发送指令，无需切换窗口，始终保持专注状态。\n- **一键智能修复**：光标停在 Flycheck 报错处，调用命令即可让 claude-code.el 自动附带文件路径和行号上下文，瞬间获得修复方案。\n- **多实例并行协作**：为不同功能模块开启独立的 Claude 会话，利用 transient 菜单轻松管理多个并行任务，互不干扰。\n- **键盘流高效交互**：通过 `\u003Creturn>` 或数字键快速回复，利用模式循环快捷键在“自动接受”与“确认模式”间无缝切换，操作如行云流水。\n\nclaude-code.el 将强大的 AI 编程助手深度融入 Emacs 工作流，让开发者在不中断思路的前提下实现代码的快速迭代与修复。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fstevemolitor_claude-code.el_2b48de4f.png","stevemolitor","Steve Molitor","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fstevemolitor_b88a6395.jpg",null,"stevemolitor@gmail.com","https:\u002F\u002Fgithub.com\u002Fstevemolitor",[82,86,90],{"name":83,"color":84,"percentage":85},"Emacs Lisp","#c065db",97.7,{"name":87,"color":88,"percentage":89},"Shell","#89e051",1.5,{"name":91,"color":92,"percentage":93},"Makefile","#427819",0.8,678,62,"2026-04-09T08:42:41","Apache-2.0",4,"未说明 (基于 Emacs 和 Claude Code CLI，通常支持 Linux\u002FmacOS\u002FWindows)","无本地 GPU 需求 (依赖远程 Claude API)","未说明",{"notes":103,"python":104,"dependencies":105},"该工具是 Emacs 编辑器插件，而非本地运行的 AI 模型。核心前提是必须安装并配置好 'Claude Code CLI' 且拥有有效的 Anthropic API 访问权限。主要运行环境为 Emacs 30.0 及以上版本。可选依赖包括终端模拟器 eat 或 vterm，以及用于 IDE 集成的 Monet 包。","无 Python 版本需求",[106,107,108,109,110,111,112],"Emacs >= 30.0","Claude Code CLI","transient >= 0.7.5","inheritenv >= 0.2","eat >= 0.9.2 (可选)","vterm (可选)","Monet (可选)",[15,25],"2026-03-27T02:49:30.150509","2026-04-11T10:01:30.989355",[117,122,127,132,137,142],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},29246,"如何在 claude-code.el 中使用 vterm 替代 eat 终端？","要使用 vterm 作为后端，请确保已安装 vterm（参考 https:\u002F\u002Fgithub.com\u002Fakermu\u002Femacs-libvterm），然后获取最新版本的 claude-code.el。接着在配置中设置变量：\n(setq claude-code-terminal-backend 'vterm)\n此外，还可以查看 README 中关于 Vterm 特定配置和 `claude-code-optimize-window-resize` 的自定义选项。","https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\u002Fissues\u002F18",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},29247,"在 claude-code 会话中粘贴多行提示词后，按回车键无法执行，如何解决？","在 eat 缓冲区中，不能使用 Command-V (Mac) 或 Control-V (Windows) 进行粘贴。必须使用 Emacs 的原生粘贴命令 `C-y` (即 `eat-yank`)。如果粘贴大段文本后回车仍无效，建议尝试切换到 vterm 后端，或者检查是否在普通 eat 缓冲区中也存在相同问题。","https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\u002Fissues\u002F62",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},29248,"启动时出现 native-compiler 警告且 eat 终端颜色显示异常怎么办？","对于颜色显示异常或字体对齐问题（特别是使用 SF Mono 字体时），可以通过添加 advice 来过滤输出中的特殊 Unicode 字符。例如，将导致布局问题的字符替换为语义相似的 ASCII 字符：\n(defvar sm-subsitutions '((?✢ . ?+) (?✳ . ?*) (?∗ . ?*) (?✻ . ?*) (?✽ . ?*) (?🤖 . ?*)))\n(defun sm-replace-problem-chars (args)\n  (let ((terminal (nth 0 args)) (output (nth 1 args)))\n    (dolist (sub sm-subsitutions) (setq output (subst-char-in-string (car sub) (cdr sub) output)))\n    (list terminal output)))\n(advice-add 'eat-term-process-output :filter-args #'sm-replace-problem-chars)\n如果问题严重，也可以替换所有非 ASCII 字符为空格（但这会丢失所有 Unicode 内容）。","https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\u002Fissues\u002F1",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},29249,"如何正确配置 monet 集成以自动启动 IDE 模式？","不能直接在 `use-package` 的 `:hook` 声明中使用 `claude-code-process-environment-functions`，因为它是一个异常钩子（abnormal hook）。必须在 `:config` 部分显式调用 `add-hook`：\n(add-hook 'claude-code-process-environment-functions #'monet-start-server-function)\n这样可以确保在启动时正确加载环境变量并进入 IDE 模式。","https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\u002Fissues\u002F83",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},29250,"是否有办法用一个快捷键同时实现切换窗口和聚焦到 claude-code 缓冲区？","目前可以通过组合键实现，但维护者计划添加一个 DWIM (Do What I Mean) 命令或选项来实现单键操作。预期的行为逻辑是：如果没有运行实例则创建并切换；如果有运行实例则切换显示状态并在打开时聚焦；如果有多个实例且无缓冲区打开，则打开最近使用的实例并聚焦。用户可以关注后续更新以获取名为 `claude-code` 的智能命令。","https:\u002F\u002Fgithub.com\u002Fstevemolitor\u002Fclaude-code.el\u002Fissues\u002F76",{"id":143,"question_zh":144,"answer_zh":145,"source_url":126},29251,"为什么在 Mac 上使用 Command-V 无法在 claude-code 缓冲区粘贴内容？","这是因为 claude-code 默认使用 eat 终端模拟器，而 eat 缓冲区不支持系统级的粘贴快捷键（如 Mac 的 Command-V 或 Windows 的 Control-V）。在 eat 缓冲区中，必须使用 Emacs 标准的粘贴命令 `C-y` (对应函数 `eat-yank`) 才能成功粘贴剪贴板内容。",[]]