【文章标题】:e is a customizable self-aware Emacs-like editor written in Chez Scheme
【文章标题】:e是一款用Chez Scheme编写的可定制自感知类Emacs编辑器
【文章正文】:
A tiny console text editor written in Chez Scheme. It is Emacs-like in spirit—buffers, windows, a kill ring, incremental search, and a Scheme top level—but it is not an Emacs clone. It borrows the ideas that stay small and stops there.
用Chez Scheme编写的微型控制台文本编辑器。其精神内核与Emacs相似——缓冲区、窗口、剪切环、增量搜索和Scheme顶层环境——但并非Emacs的克隆版。它仅借鉴了保持精简的设计理念便适可而止。
-
The editor is a Scheme system. Everything is an R6RS library: a minimal core with a published, immutable API, and extension modules built on it (the syntax modes, bracket matching, the editing helpers, M-x itself). The core enforces its boundaries with the language rather than with discipline: internals are invisible, exports cannot be reassigned.
-
该编辑器本质是Scheme系统。所有组件都是R6RS库:包含发布后不可变的API的最小化核心,以及构建其上的扩展模块(语法模式、括号匹配、编辑助手、M-x功能本身)。核心通过语言特性而非规范来强制边界:内部实现不可见,导出内容不可重定义。
-
M-x evaluates Scheme against the editor’s live top level, with symbol completion, parameter hints as you type, history, and a transcript buffer.
-
M-x在编辑器实时顶层环境中执行Scheme代码,支持符号补全、输入时的参数提示、历史记录及交互缓冲区。
-
Modules hot-reload. Saving a module’s source inside the editor reloads it into the running session; sources edited elsewhere are picked up with reload-module! . Registrations are replaced, dependent modules recompile, buffers stay put. e is developed from inside itself.
-
模块支持热重载。在编辑器内保存模块源码会立即重载到运行会话中;外部修改的源码可通过reload-module!加载。注册项会被替换,依赖模块重新编译,缓冲区保持原位。e的研发过程就是在自身内部完成的。
-
No dependencies beyond Chez Scheme and a Unix-like terminal. There is no build or installation step: a checkout runs in place. The first start compiles the libraries; later starts take about 100 ms.
-
仅依赖Chez Scheme和类Unix终端。无需构建或安装步骤:检出即可运行。首次启动会编译库文件,后续启动仅需约100毫秒。
-
Undo reports what it undoes: Undo insert “hello” ,Undo (replace-all! “xx” “yy”) . Typed characters coalesce into runs, a paste is a single step, an M-x command is one labeled step.
-
撤销操作会报告具体内容:如”撤销插入’hello’”、“撤销(replace-all! “xx” “yy”)“。连续键入字符会合并为整体操作,粘贴视为单步,M-x命令作为带标签的独立步骤。
As your everyday editor, cloned as /.e:/.e:
作为日常编辑器,可克隆到
git clone https://github.com/paveluv/e ~/.e
~/.e/e file.txt # add ~/.e to PATH for plain `e`
Or vendored inside a project, so anyone who clones the project gets a working editor with it:
或内置于项目中,使项目克隆者自动获得可用编辑器:
git clone https://github.com/paveluv/e ~/git/your_project/.e
rm -rf ~/git/your_project/.e/.git # make it ordinary files of your repo
~/git/your_project/.e/e file.txt
Every installation is self-contained: the loader uses strictly the lib/ next to the script itself, compiled objects stay local in eo/, and sources recompile automatically when they (or anything they import) change. Project-specific modules dropped into a vendored checkout’s lib/ stay local to that project.
每个安装都是自包含的:加载器严格使用脚本同目录的lib/,编译对象保存在eo/,源码(或其导入项)变更时自动重编译。置于项目内lib/的专属模块仅对该项目有效。
The terminal size is detected via ioctl and tracked across resizes; if that is unavailable, set LINES and COLUMNS. On FreeBSD, whose Chez port renames the scheme-script interpreter, change the shebang to #!/usr/bin/env -S chez-scheme —script or run chez-scheme —script e (details in the loader’s header comment).
终端尺寸通过ioctl检测并跟踪调整;若不可用则需设置LINES和COLUMNS环境变量。FreeBSD系统的Chez移植版重命名了scheme-script解释器,需将shebang改为#!/usr/bin/env -S chez-scheme —script或直接运行chez-scheme —script e(详见加载器头部注释)。
快捷键对照表:
| Key | Action |
|---|---|
| C-x C-s | 保存(未命名缓冲区会提示输入名称) |
| C-x C-w | 另存为:输入路径后缓冲区将关联该文件 |
| C-x C-f | 在独立缓冲区打开文件(必要时创建) |
| C-x C-c | 退出(仅当缓冲区与文件内容不一致时询问) |
| Key | Action |
|---|---|
| C-x b | 切换缓冲区(默认:最近使用的其他缓冲区;新名称会创建缓冲区) |
| C-x C-b | 打开缓冲区列表:用上下箭头移动,回车选择;点击直接选中 |
| M-Up | 按字母顺序切换到上一个缓冲区 |
| M-Down | 按字母顺序切换到下一个缓冲区 |
| C-x k | 关闭缓冲区(默认当前缓冲区;若已修改会询问) |
| C-x 2 | 垂直分割当前窗口 |
| C-x 3 | 水平分割当前窗口 |
| C-x 1 | 关闭其他所有窗口 |
| C-x 0 | 关闭当前窗口 |
| C-x o | 跳转到下一个窗口 |
| C-x t | 切换当前窗口的自动换行功能 |
每个窗口拥有独立的状态栏、光标位置和滚动位置;同一缓冲区可同时在多个窗口显示。缓冲区自带历史记录和标记;窗口则独立维护光标、滚动、换行和状态。默认显示右侧滚动条;C-x l切换显示行号边栏。详见缓冲区管理章节(含切换逻辑、缓冲区列表、文件完整性、目标窗口、鼠标行为、滚动条、换行、分割及公共API)。
| Key | Action |
|---|---|
| C-b /C-f / 方向键 | 左/右移动一个字符 |
| C-p /C-n / 方向键 | 上/下移动一行 |
| C-a /C-e , Home/End | 跳至行首/行尾 |
| C-v /M-v , PgDn/PgUp | 向下/向上翻页 |
| M-< /M-> | 跳至缓冲区开头/结尾 |
| Key | Action |
|---|---|
| C-d , Delete | 删除光标后字符 |
| Backspace | 删除光标前字符 |
| C-o | 在下方插入空行,保持光标位置 |
| C-k | 剪切至行尾(可重复操作累积) |
| C-@ (C-Space ) | 设置标记 |
| C-w | 剪切标记与光标间区域 |
| C-y | 粘贴最近剪切内容 |
| C-_ | 撤销 |
| C-M-_ | 重做 |
| TAB | 按当前模式规则缩进行 |
| M-% | 从光标处查询替换:y/空格键替换,n/DEL跳过,q/回车/C-g终止 |
| M-. | 描述光标处符号(Scheme缓冲区专用,见下文) |
| C-x C-e | 将当前缓冲区作为Scheme代码求值 |
| C-l | 重绘屏幕并重读终端尺寸 |
| C-g | 取消(提示、搜索、标记、正在进行的求值) |
| C-h k | 查看按键绑定来源及功能说明 |