mcpField
E
emacsclient

emacsclient

github.com/xenodium开发147119 次安装14 周前更新
代码仓库

关于 emacsclient

面向使用已运行 Emacs 服务的编码 Agent,规定所有 Emacs 操作都通过 `emacsclient` 执行。适用于打开文件、执行 Elisp、编译、检查和运行测试。

主要功能

  1. 01所有操作均使用 `emacsclient`
  2. 02打开文件时不等待
  3. 03执行 Elisp 表达式
  4. 04编译和检查 Elisp 文件
  5. 05运行 ERT 测试

适用场景

  1. 01打开指定行的文件
  2. 02执行 Elisp 表达式
  3. 03检查括号或字节编译文件
  4. 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