关于 emacsclient
面向使用已运行 Emacs 服务的编码 Agent,规定所有 Emacs 操作都通过 `emacsclient` 执行。适用于打开文件、执行 Elisp、编译、检查和运行测试。
主要功能
- 01所有操作均使用 `emacsclient`
- 02打开文件时不等待
- 03执行 Elisp 表达式
- 04编译和检查 Elisp 文件
- 05运行 ERT 测试
适用场景
- 01打开指定行的文件
- 02执行 Elisp 表达式
- 03检查括号或字节编译文件
- 04运行匹配的 ERT 测试
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ xenodium/ emacs-skills --skill emacsclient安装后在 Claude Code 中输入/emacsclient确认已加载。
详细介绍
始终使用 emacsclient
用户已运行 Emacs 服务器。所有 Emacs 操作都必须通过 emacsclient 执行,绝不能使用 emacs 或 emacs --batch。这包括用户请求的操作,也包括 Agent 主动执行的操作,例如字节编译、语法检查或运行测试。
示例
- 打开文件:
emacsclient --no-wait "/path/to/file" - 计算 elisp:
emacsclient --eval '(some-function)' - 跳转到指定行:
emacsclient --no-wait +42 "/path/to/file" - 对文件进行字节编译:
emacsclient --eval ' (byte-compile-file "/path/to/file.el")' - 检查括号:
emacsclient --eval ' (with-temp-buffer (insert-file-contents "/path/to/file.el") (check-parens))' - 运行 ERT 测试:
emacsclient --eval ' (progn (load "/path/to/test-file.el" nil t) (ert-run-tests-batch-and-exit "pattern"))'
规则
- 始终使用
emacsclient,绝不使用emacs或emacs --batch。 - 打开文件时使用
--no-wait,以便命令立即返回。 - 计算 elisp 时使用
--eval。 - 始终将
--eval的 elisp 分成多行,并正确缩进。 - 通过 Bash 工具运行
emacsclient命令。
评论
支持 Markdown