(分享)知名开发者 Matt Gemmell 谈 Emacs

原文:emacs — Matt Gemmell

A couple of years ago I was standing outside my son’s nursery, waiting to pick him up at the end of the day. I got chatting to another father, whose name was Tafuma, and once we’d negotiated the usual pleasantries and parenthood-centric remarks, we discovered that we both had a technology background.

几年前,我站在儿子的托儿所外,等待一天结束时去接他。我和另一位父亲交谈起来,他的名字叫 Tafuma,在我们寒暄并谈论了一些以父母身份为中心的话题后,我们发现我们都具有技术背景。

Virtually without additional preamble, he asked “Have you heard of org mode?”

几乎没有任何额外的开场白,他问道:“你听说过 org mode 吗?”

I truthfully answered that I had, but I’d bounced off the project’s homepage every time, for the two main reasons that it seemed like overkill for my needs, and that I had no experience with emacs, the editor within which org mode runs.

我确实回答了是的,但我每次访问项目的首页时都会犹豫不决,主要有两个原因:它似乎对我来说过于复杂,而且我对 Emacs 没有经验,而 org 模式是在 Emacs 这个编辑器中运行的。

I’ve used command-line text editors before. I administer this server, and can get around in vi or nano quite comfortably for basic tasks. I even used mutt as my primary email client for a while, and it has the same interface. Emacs, though, remained a mystery.

我之前使用过命令行文本编辑器。我管理这台服务器,对于基本任务,我可以在 vi 或 nano 中很舒适地操作。我还曾一段时间将 mutt 作为我的主要电子邮件客户端,它有相同的界面。然而,Emacs 仍然是个谜。

Recently, I’ve made some significant changes in my tech setup. I switched back to Mac, after eight years on the iPad. I’ve also been feeling increasingly dissatisfied with Apple as a company. They care about privacy, but not choice; security, but not liberty. I suppose it’s natural enough that, after almost a decade locked into the walled garden of a wholly vendor-controlled device and their own app store, I feel disproportionately aggrieved when I notice the invisible walls of lock-in and proprietary services and silos.

最近,我在我的技术设置上做了一些重大改变。我在使用 iPad 八年之后,又换回了 Mac。我也越来越不满意苹果公司。他们关心隐私,但不关心选择;关心安全,但不关心自由。我想,在几乎一个十年的完全受供应商控制的设备及其自有应用商店的围墙花园中锁定之后,当我注意到锁定和专有服务及隔间的无形墙壁时,我感到不公正的程度不成比例,这是很自然的。

I love macOS, and I won’t be moving away from it any time soon, but I do want my setup to be more platform-agnostic, and I very much want to have ownership of my data. To that end, I’ve taken some steps towards getting some of my most valuable data into open formats and app-agnostic storage.

我爱 macOS,而且我不会很快离开它,但我确实希望我的设置能更加跨平台,我非常希望拥有我的数据。为此,我已经采取了一些措施,将我一些最有价值的数据转移到开放格式和应用程序无关的存储中。

My beloved Ulysses is a Markdown editor at heart, with lots of useful ancillary features including export configurations for publishing both digital and print books, and some editing conveniences which I’ve made occasional use of in the past. It’s been the repository of most of my writing for years, and is available on all of the Apple device platforms. It’s wonderful, and I highly recommend it for the majority of people who want to write in Markdown on an Apple device, and publish their work.

我挚爱的 Ulysses 是一款以 Markdown 编辑器为核心的软件,拥有许多实用的辅助功能,包括用于发布数字和印刷书籍的导出配置,以及一些我过去偶尔使用的编辑便利功能。多年来,它一直是我的大部分写作的存储库,并且可以在所有苹果设备平台上使用。它非常出色,我强烈推荐大多数想在苹果设备上使用 Markdown 写作并发布作品的人使用它。

There are a couple of sub-optimal aspects, though. Using the full set of features entails keeping your work in its own internal format, which is essentially a big opaque archive with all the necessary metadata and so on. That’s fine, and inevitable, but not what I’m quite comfortable with right now. You can export to regular Markdown (Ulysses uses its own variant with some unique syntax), even in bulk, but you’ll of course lose any proprietary types of annotations or attachments like separate per-document notes, images, and keywords. You’ll also lose any custom ordering of documents within a group, understandably, but I was able to ameliorate this by merging any custom-ordered groups into a single document — those files are just concatenated into one big Markdown document for export anyway — and thus preserve the overall intent. It took a couple of hours of faffing around, but I now have all of my writing, as vanilla Markdown files, in a suitable directory structure that can be read by anything that can cope with plain text.

不过,也有一些不太理想的地方。使用完整功能意味着将你的工作保存在其自身的内部格式中,这本质上是一个包含所有必要元数据等的大而不可见的归档文件。这没什么大不了,也是必然的,但就我个人而言,目前还不太习惯。你可以导出为常规的 Markdown(Ulysses 使用自己的变体,带有一些独特的语法),甚至可以批量导出,但这样一来,你当然会失去任何专有的注释类型或附件,比如独立的每份文档笔记、图片和关键词。你也会失去文档组内的任何自定义排序,这可以理解,但我通过将任何自定义排序的组合并为单个文档来改善这个问题——那些文件反正导出时就是简单地连接成一个大的 Markdown 文档——从而保留了整体意图。虽然折腾了好几个小时,但现在我的所有写作,都以纯 Markdown 文件的形式,保存在一个适合任何能处理纯文本的软件读取的目录结构中。

So I have the data. Now what about the editor?

所以我有数据了。那么编辑器呢?

I had a lot of preconceptions about emacs, split pretty evenly between what I thought it was, and what I thought it wasn’t. I have to admit that, knowing what I now know, I didn’t have a good hit rate at all in my assumptions. Nor even did I have a good grasp of what the pros and cons of it would turn out to be, for me or for users in general.

我对 emacs 有很多先入为主的观念,这些观念在我认为它是什么和我认为它不是什么之间相当均衡。我必须承认,根据我现在所知,我在假设方面并没有很高的命中率。甚至我也没能很好地把握它对我或一般用户而言的优缺点会是什么。

The thing with emacs is that its pros and cons are all extremely subjective. Certainly, it’s not for most people who are coming from typical GUI apps. We should avoid categorising differences as weaknesses per se, of course, but learning curve is a legitimate factor, and emacs definitely has one. Everything does, though; especially things that are ultimately worthwhile. The initial experience is rarely the full story, or even a representative part of it.

关于 emacs,它的优点和缺点都极其主观。当然,它并不适合大多数来自典型 GUI 应用的用户。我们当然应该避免将差异简单地归类为弱点,但学习曲线确实是一个合理的因素,而 emacs 肯定有这个特点。所有东西都有;尤其是那些最终值得的事情。最初的体验很少是全部故事,甚至也不是其有代表性的部分。

I’ve spent a few weeks using emacs for hours every day, fiddling with its innards, reading the entirety of its manual, and using it for my work. I’ve learned a lot that’s surprised me. Here are some of the things that stood out.

我花了几周时间每天使用 emacs 数小时,摆弄它的内部结构,阅读了它的全部手册,并用它来处理工作。我学到了很多让我惊讶的东西。这里列出了一些突出的方面。

emacs is a GUI app for ten-fingered typists

emacs 是为十指打字者设计的 GUI 应用

First, emacs isn’t a terminal-based text editor. It can be, if you want, but it’s primarily a windowed application at least superficially analogous to Notepad or TextEdit or such. You don’t need to visit the command-line to launch or use it, unless you want to.

首先,emacs 不是基于终端的文本编辑器。如果你愿意,它可以是的,但至少表面上,它是一个窗口化的应用程序,类似于记事本或 TextEdit 之类的应用。你不需要访问命令行来启动或使用它,除非你愿意。

That said, it’s very different from most GUI apps. Let me say up front that if you’re a mouse type of person, using a pointing device to trigger menu items and to click buttons, you need read no further; emacs isn’t for you. I’ve always tried to avoid my pointing device whenever possible, greedily learning keyboard shortcuts so I can keep my hands on the keyboard and my eyes on the screen. If that sounds like you, too, then emacs is at least viable for you.

话说回来,它和大多数 GUI 应用程序非常不同。让我开门见山地讲,如果你是习惯使用鼠标的人,用指针设备来触发菜单项和点击按钮,你就不需要再继续阅读了;emacs 不适合你。我一直尽量避免使用我的指针设备,贪婪地学习键盘快捷键,这样我就能保持双手在键盘上,眼睛盯着屏幕。如果你也这样,那么 emacs 至少对你来说是有可行性的。

emacs has sequential keyboard shortcuts

emacs 有顺序键盘快捷键

The next big thing is the nature of those keyboard shortcuts: they look different than you’re used to, and they’re constructed differently. There are two main parts to this.

下一个重点是他们键盘快捷键的性质:它们看起来和你习惯的不同,而且构造方式也不同。这有两部分主要构成。

  1. Due to historical reasons and also its cross-platform nature, emacs doesn’t use the familiar symbols for keyboard shortcuts on your chosen operating system. You won’t see the key on the Mac, or the symbol for Control/Ctrl, or whatever. Emacs does use those keys, of course; it just notates them differently, and indeed in plain text. It’s pretty simple: Shift is S, Control or Ctrl is C, Alt or Option is M (for Meta), and Command on Mac or the Windows key on Windows is s (note the lowercase), for Super.

由于历史原因以及它的跨平台特性,emacs 不会在你选择的操作系统上使用熟悉的键盘快捷键符号。你不会在 Mac 上看到 键,也不会看到 符号代表 Control/Ctrl,或者任何其他符号。Emacs 当然会使用这些键;只是表示方式不同,而且确实是用纯文本表示。很简单:Shift 是 S ,Control 或 Ctrl 是 C ,Alt 或 Option 是 M (代表 Meta),Mac 上的 Command 键或 Windows 上的 Windows 键是 s (注意小写),代表 Super。

The way those shortcuts are displayed is also a tiny bit different, using hyphens to indicate that keys should be pressed simultaneously. So, for example, the macOS shortcut of ⌃⌥N (meaning to simultaneously press Control, Option, and the N key) would be shown in emacs as C-M-n. Emacs uses lowercase letter keys in shortcuts, and would only show the uppercase version if you really were meant to include the Shift key to type it in uppercase; macOS, for whatever reason, shows shortcut letters always in uppercase, even though you’re typing them in lowercase.

这些快捷键的显示方式也有点不同,使用连字符来表示应该同时按下按键。所以,例如,macOS 的快捷键 ⌃⌥N (表示同时按下 Control、Option 和 N 键)在 emacs 中会显示为 C-M-n 。Emacs 在快捷键中使用小写字母键,只有当你确实需要包括 Shift 键来输入大写字母时,才会显示大写版本;而 macOS,无论出于什么原因,始终以大写形式显示快捷键字母,即使你正在以小写形式输入。

  1. The second difference is that the GUI keyboard shortcuts you’re used to are virtually always just a single splat of keys, all pressed at the same time. In emacs, though, almost all shortcuts are sequences of key-presses or combinations. Here’s an example: M-x C-s means to press Meta (which is Alt/Option, remember) and x at the same time, then release those keys and press Control and s. This actually gives a huge amount of flexibility, since the first part of the shortcut selects a whole group of further shortcuts, in a hierarchy, giving far more keyboard control without requiring increasingly uncomfortable multi-key simultaneous combinations.

第二个区别在于你习惯的 GUI 键盘快捷键几乎总是同时按下单个按键。但在 emacs 中,几乎所有快捷键都是按键序列或组合。这里有一个例子: M-x C-s 表示同时按下 Meta(记住它是 Alt/Option)和 x,然后松开这些键并按下 Control 和 s。这实际上提供了巨大的灵活性,因为快捷键的第一部分选择了一组进一步的快捷键,按层次结构排列,从而在不需要越来越不舒服的多键同时组合的情况下,提供了更多的键盘控制。

You get used to it quickly, and then you realise just how powerful it is. And you can remap any of the shortcuts for anything at all: I really mean that. Not just for the menu commands. Not just for things that already have a shortcut. For anything at all.

你很快就会习惯它,然后你才会意识到它有多么强大。而且你可以重新映射任何快捷键用于任何事:我说的可是真的。不只是用于菜单命令。不只是用于那些已经有了快捷键的东西。用于任何事。

emacs has more features than any other app

emacs 比任何其他应用都有更多功能

You’re thinking that I’m exaggerating right now. I am not. Emacs has more functionality than probably any other app on your system, of any kind, by a very large margin. It can replace, at least to a substantial degree, most apps that deal with any kind of data that can conceivably be rendered in a primarily textual format, and that grouping is very much larger than you presently think.

你可能在想我此刻是在夸大其词。我并不是。Emacs 的功能性远超你系统上任何种类的其他应用,差距非常大。它至少在很大程度上可以替代处理任何理论上可以以主要文本格式呈现的数据的大多数应用,而这个范围比你目前所想的要大得多。

I haven’t been using emacs for very long and have made only minimal customisations, but when I trigger the global shortcut to execute an arbitrary command, I get a list of 6,183 options at the moment, and there are over 10,000 commands built-in, before you start adding optional packages. Amongst literally thousands of other things, emacs is (and can be) a writing tool, programming IDE, calendar and agenda app, web browser, mail client, file browser, terminal, presentation tool, spreadsheet, finance tracker, media player, page-layout app, personal knowledge management repository, version control system, and a ridiculous number of other things. It has its own package manager, and its own customisation interface, but the main thing is that it’s modular.

我使用 emacs 的时间还不长,只做了最少的定制,但当我触发全局快捷键执行任意命令时,目前我能得到 6,183 个选项,而且在你开始添加可选包之前,内置命令就超过 10,000 个。在成千上万的其他功能中,emacs 是(并且可以是)一个写作工具、编程 IDE、日历和日程应用、网络浏览器、邮件客户端、文件浏览器、终端、演示工具、电子表格、财务追踪器、媒体播放器、页面布局应用、个人知识管理仓库、版本控制系统,以及其他无数的功能。它有自己的包管理器和定制界面,但最重要的是它是模块化的。

On the one hand, your favourite features in your current word processor or text editor or IDE were very possibly inspired by emacs, which has been around for a very long time. The first version was written in 1976. The most recent version, 30.1, was released in February 2025. And on the other hand, if you have some favourite features from other apps that evolved independently, they are very likely also available in emacs.

一方面,你当前使用的文字处理软件、文本编辑器或 IDE 中的喜爱功能很可能受到了 emacs 的启发,而 emacs 已经存在了非常长的时间。第一个版本写于 1976 年。最新版本 30.1 于 2025 年 2 月发布。另一方面,如果你从其他独立发展的应用程序中有一些喜爱的功能,它们很可能也存在于 emacs 中。

emacs is your favourite editor

emacs 是你的最爱编辑器

What this means is that emacs is not just customisable, but composable. Before I started using Ulysses, I spent years with Scrivener, which is another fantastic writing app; it just focuses on styled text instead of Markdown, and has many more planning and brainstorming conveniences. I always particularly liked its binder, with a three-pane setup of the file tree, the per-file notes, and the current document. Emacs has that. In Ulysses, I liked the Markdown editor and syntax-insertion and export via stylesheets instead of complicated configuration windows. Emacs has that too. At this point, if emacs doesn’t have a particular feature, either built-in or installable, it’s not even a choice; it’s an anomaly.

这意味着 emacs 不仅可定制,而且可组合。在我开始使用 Ulysses 之前,我花了数年时间使用 Scrivener,它也是另一个非常棒的写作应用程序;它专注于样式化的文本而不是 Markdown,并且有更多的规划和头脑风暴便利功能。我总是特别喜欢它的资料夹,它有一个三窗格的文件树、每个文件的笔记和当前文档的设置。Emacs 也有这个功能。在 Ulysses 中,我喜欢 Markdown 编辑器、通过样式表进行语法插入和导出,而不是复杂的配置窗口。Emacs 也有这些功能。在这个阶段,如果 emacs 没有某个内置或可安装的特定功能,那它甚至不是一个选择;它是一个异常。

It also has a composable interface, whereby you can readily set up whatever combination of split views and embedded functionality you like. By all means recreate what you’re used to elsewhere. Recreate the key bindings and workflows, and the colour schemes and layouts. Nobody’s going to stop you, and somebody has already done it anyway. Or make an entirely new editor that just suits you in particular, because there’s some stuff you like from Xcode, and some from Jetbrains, and some from Visual Studio and Eclipse and whatever people are using these days. Or Scrivener and Ulysses and Writeroom and iA Writer. Or all of it at the same time, morphing as you switch between different file types or mo∫ods.

它还拥有一个可组合的界面,你可以轻松设置各种分割视图和嵌入式功能的组合。尽管去重新创建你习惯使用的其他地方的功能。重新创建快捷键和工作流程,以及配色方案和布局。没有人会阻止你,而且已经有人这样做了。或者制作一个完全适合你自己的新编辑器,因为你喜欢 Xcode 的一些功能,Jetbrains 的一些功能,Visual Studio 和 Eclipse 以及现在人们使用的一切。或者 Scrivener、Ulysses、Writeroom 和 iA Writer。或者同时使用所有这些,在你切换不同文件类型或模式时变形。

But let’s calm down for a minute.

但让我们先冷静一分钟。

emacs is an instrument

emacs 是一个工具

Things are different in emacs. There’s the modular nature of it, and the acclimatisation period for the keyboard shortcuts and how they work. But there’s more than that. Some of the terminology is different (windows are frames, and panes are windows, and loaded documents are buffers, and cut/copy/paste work a bit differently via something called the kill ring, which I think we can all agree is a wonderful name no matter what it does).

在 emacs 中情况不同。它具有模块化特性,以及键盘快捷键的适应期和它们的工作方式。但不仅如此。有些术语也不同(窗口是框架,窗格是窗口,加载的文档是缓冲区,剪切/复制/粘贴通过一个称为 kill ring 的东西工作,我认为我们都同意这个名字无论它做什么都非常好)。

Everything is a buffer in emacs, and you can navigate and manipulate all of it, and you will be doing so all the time. Back and forth and up and down, whizzing around, looking like you’re hacking the planet. Clackety clackety clack. And, little by little, you’ll get surprisingly fast at getting things done, and getting to where you need to be. Think about it: no matter how weird and scary it looks at first, this thing has been in development for nearly fifty years, and is used by people (albeit weird people?) on every platform out there, for every kind of task. They can’t all be wrong. But they all had to learn how to use the thing, and to adapt to its very particular way of working. You’ll be no different, either in the initial confusion or in the growing comfort and wonder.

在 emacs 中,一切都是一个缓冲区,你可以导航和操作所有内容,并且你将一直这样做。来回上下,快速穿梭,看起来像是在对整个星球进行黑客攻击。咔哒咔哒咔哒。慢慢地,你会惊讶地发现自己完成任务的效率有多高,以及到达需要去的地方有多快。想想看:无论它最初看起来多么奇怪和吓人,这个工具已经开发了近五十年,并且被世界各地的人们(尽管可能是奇怪的人)在各种平台上用于各种任务。他们不可能都错。但他们都必须学会如何使用这个工具,并适应它非常独特的工作方式。你也不会例外,无论是在最初的困惑中,还是在逐渐的舒适和惊奇中。

But seriously, don’t bother if you’re not into plain text, and typing keyboard shortcuts, and keeping your hands off the mouse or trackpad or whatever it is you use. I’m not kidding. You should absolutely change your filthy habits, but if you don’t intend to do so, emacs isn’t for you.

但说真的,如果你不喜欢纯文本、不习惯输入快捷键、不想离开鼠标或触控板,那就别费心了。我说的可是真的。你应该彻底改变那些糟糕的习惯,但如果不想改变,emacs 就不适合你。

That’s not to say that emacs won’t help you, though! There’s a thing called the mode line at the bottom of every frame, giving feedback on what’s happening, and asking for input when needed, and showing useful information. You can ask emacs which commands are available, and which shortcuts, and what a given shortcut does, and what a given command does, and how to configure something, and what a particular thing means. There’s also a vast manual built into the thing, which you can also read online, and user communities in every corner of the internet. Every question you want to ask has an answer available, and has been asked and answered before. I find that quite comforting, knowing that instead of a piece of software being a blip in my life that I’ll eventually move on from, I’m actually just a blip in emacs’ life.

但这并不意味着 emacs 会对你毫无帮助!每个窗口底部都有一个叫做模式行的东西,它会提供反馈、在需要时请求输入,并显示有用信息。你可以询问 emacs 有哪些命令可用、哪些快捷键、某个快捷键的作用、某个命令的功能、如何配置某项内容、某个特定内容的意思。此外,这个软件内置了庞大的手册,你也可以在线阅读,互联网的每个角落都有用户社区。你想问的每一个问题都有答案,而且这些问题之前已经被提出并解答过。我知道这一点让我感到很安心,因为这意味着 emacs 对我来说不是一段会最终被遗忘的软件,而是我对于 emacs 来说只是一段短暂的时光。

It took me about a week to feel comfortable with emacs, and no longer reach for BBEdit (another of the finest text editors of all time, most definitely, and my favourite macOS app) when precision and rapidity of editing were needed. Another few days, and I had the same feeling as when I’ve tweaked a mechanical keyboard layout and finally managed to internalise it; that sense that my hands knew what I wanted to do, and consciously thinking about it makes me slower rather than faster. It’s the same feeling you get when you play a musical instrument.

花了我大约一周时间才对 emacs 感到熟悉,不再在需要精确和快速编辑时伸手去用 BBEdit(毫无疑问,这是有史以来最优秀的文本编辑器之一,也是我最喜欢的 macOS 应用)。又过了几天,我有了和调整机械键盘布局后终于内化它的感觉一样的感觉;那种感觉就是我的手知道我想做什么,而刻意去想反而会让我变慢而不是变快。这和你弹奏乐器时得到的感觉是一样的。

emacs is modal

emacs 是模态的

The single greatest strength of emacs is its pervasive modality. Modal, in the context of computing, just means being in a particular state (or mode) which affects how input is interpreted. Caps Lock is a mode, because it makes the computer interpret your press of the ‘k’ key as the uppercase ‘K’ instead. The Shift key also creates a mode, whereby the number keys produce symbols instead, and so on.

emacs 最大的优势在于其普遍的模态性。在计算机的语境中,模态仅仅意味着处于特定的状态(或模式),这会影响输入的解读方式。大写锁定键就是一个模式,因为它让计算机将你按下的‘k’键解读为大写的‘K’。Shift 键也创建了一个模式,在这个模式下,数字键会输出符号,等等。

Lots of people think that modal actually means doing just one thing at a time, or a type of interface that pops up and blocks what you’re doing until you’ve dealt with it. I’m using the term in its defined sense from the previous paragraph.

很多人认为"modal"实际上是指一次只做一件事,或者是一种弹出并阻止你当前操作直到你处理完它的界面类型。我使用的是前一段定义的术语。

The way emacs works is that it has many different modes, split into either major or minor categories. Only one major mode can be active in each buffer (think of it like a document window), but you can have as many minor modes active as you like. You can even have minor modes active globally, instead of just in a given set of buffers.

emacs 的工作方式是它有多个不同的模式,分为主要或次要类别。每个缓冲区(可以想象成文档窗口)中只能有一个主要模式处于活动状态,但你可以激活任意数量的次要模式。你甚至可以全局范围内激活次要模式,而不仅仅是在特定的缓冲区集中。

You’re probably familiar with the basic idea of what emacs calls major modes. Your IDE, for example, will presumably behave a bit differently and have different commands available when you’re editing a python source file versus a markdown file, or an html document. Those are just modes; the python major mode, say, where invoking a “comment-out this line” command will insert the appropriate comment delimiters for the python language. You get the idea.

你可能熟悉 emacs 所称为主要模式的基本概念。例如,你的 IDE 在编辑 python 源文件与 markdown 文件或 html 文档时,行为可能会有所不同,并且可用的命令也不同。这些都是模式;比如 python 主要模式,其中执行"取消注释这一行"命令会插入适合 python 语言的适当注释分隔符。你明白这个意思。

In emacs, though, lots of functionality is split out into minor modes, which can be active in whichever buffers you like, and usually regardless of which major mode is in effect. Live spell-checking is a minor mode, as is visual line-wrapping. The ability to edit and format tables with formulae is a minor mode, nominally belonging to the org major mode, but you can readily use it for Markdown files, or in your Swift source code comments, or whatever you want. This is what I mean by emacs being composable: you can put functionality together to suit your editing session, and in a sense you can embed heterogeneous features into documents to suit your needs in the moment. It’s like OpenDoc, if anyone remembers that — or OLE, or ActiveX maybe. But I digress.

在 emacs 中,许多功能被拆分到各个小模式中,这些小模式可以在你喜欢的任何缓冲区中激活,通常不受当前主模式的影响。实时拼写检查是一个小模式,视觉行换行也是。编辑和格式化带公式的表格是一个小模式,名义上属于 org 主模式,但你完全可以将其用于 Markdown 文件,或在你的 Swift 源代码注释中,或用于任何你需要的地方。这就是我所说的 emacs 的可组合性:你可以将功能组合起来以适应你的编辑会话,在某种程度上,你可以将异构功能嵌入文档中以满足你当下的需求。这就像 OpenDoc,如果有人还记得的话——或者 OLE,或许还有 ActiveX。但我跑题了。

This turns out to be an incredibly flexible approach. Here’s an example: you might have encountered a feature in IDEs or outliners or such where you can select a portion of your document, and temporarily make it seem like there’s nothing else there, so you can dedicate your attention to just that section; it’s sometimes called focusing or hoisting. In emacs, it’s called narrowing, and it’s not dependent on any particular major mode, or on specific file types.

这证明了一种极其灵活的方法。这里有一个例子:你可能在 IDE 或大纲工具或其他类似工具中遇到过这样一个功能,你可以选择文档的一部分,暂时让它看起来好像没有其他内容,这样你就可以专注于这一部分;这有时被称为聚焦或提升。在 emacs 中,这被称为缩小,它不依赖于任何特定的主要模式,也不依赖于特定的文件类型。

Likewise, you might have encountered a feature where you can edit the same file in more than one window, and have the windows be aware of each other such that they scroll in synchronisation and trade the focus or cursor between themselves as you navigate. It’s sometimes called linked editing or such. In emacs, that’s follow mode, and it’s also a minor mode you can use whenever you like. Indeed, many major modes vend logical portions of their functionality as minor modes too, once again making me reminisce about OpenDoc.

同样,你可能在多个窗口中编辑同一个文件时遇到过这样一个功能,这些窗口能够相互感知,同步滚动,并在你导航时交换焦点或光标。这有时被称为链接编辑或类似功能。在 emacs 中,这被称为跟随模式,它也是一个你可以随时使用的次要模式。实际上,许多主要模式也将它们功能的部分作为次要模式提供,这再次让我想起 OpenDoc。

emacs has defaults instead of opinions

emacs 有默认设置而不是观点

Now I am exaggerating a little bit, because of course a default (or at least a well-chosen one) actually is an opinion. An important one. The distinction I’m making is just that emacs takes nothing for granted in terms of its appearance or behaviour; the user is given infinite rope with which to either elevate or entangle themselves. Everything is customisable. Everything.

现在我有点夸张了,因为当然,默认(或者至少是精心挑选的)实际上是一种观点。一个重要的观点。我所说的区别只是 emacs 在它的外观或行为方面从不理所当然;用户被给予无限的绳索,可以用来提升自己或陷入困境。一切都是可定制的。一切。

Here are a few examples, just off the top of my head. Everything about how every part of the interface looks, what elements are included, how windows (frames, remember) work, what features are enabled and for which modes, which keyboard shortcuts are available and what they all do, pretty much every default action or value for everything, and dozens of nuances of behaviour for every aspect of every one of thousands of commands. And you can have as many distinct sets of all that stuff as you like, in as many combinations as you want.

这里有一些例子,只是随便想想的。关于界面每个部分的外观,包含的元素,窗口(记住)的工作方式,启用的功能以及它们适用的模式,可用的键盘快捷键以及它们的作用,几乎每个默认动作或所有内容的值,以及数千个命令的每个方面的几十种行为差异。并且你可以拥有你喜欢的那样多的不同设置,以及你想要的任何组合。

Suffice to say that there’s a lot of power there, if that’s your thing. No two users’ emacs configs are the same, I daresay.

足够说那里有很多力量,如果你喜欢的话。我敢说,没有两个用户的 emacs 配置是相同的。

emacs says yes

emacs 说可以

As a consequence both of what I’ve already detailed and also the vast user community amassed over five decades, the defining quality of emacs is that, whether the question begins “Can it do” or “Does it integrate with” or even “Does it run on”, the answer is invariably yes. I’d even go so far as to say that any “can I” question regarding emacs should just be expressed as “how can I” instead.

由于我已经详细说明的内容以及五十年间积累的庞大用户社区,emacs 的标志性特质在于,无论问题以“它能不能做”或“它能不能与…集成”甚至“它能不能在…上运行”开头,答案总是肯定的。我甚至认为,关于 emacs 的任何“我能不能”的问题,都应该直接表达为“我怎么才能”。

There are limitations, of course. It’s a plain-text editor at its core, albeit festooned with absurd quantities of specialised functionality in every conceivable niche and permutation, so there are whole categories of work you won’t be doing there. But you might be surprised just how far you can go with it, if you really want to. People boot into emacs, you know. It can embed Chromium. It runs as a server. The limitations you see might just be your own lack of imagination or awareness.

当然,它也有局限性。它本质上是一个纯文本编辑器,尽管在每个可以想到的领域和变化中堆满了大量的专业功能,所以有些工作类别你无法在那里完成。但如果你真的想用,可能会惊讶于它能走多远。你知道,人们可以进入 emacs。它可以嵌入 Chromium。它可以作为服务器运行。你所看到的局限性可能只是你缺乏想象力和意识。

emacs isn’t for everyone, or even for most

emacs 并非适合所有人,甚至不适合大多数人

I think I’ve already made this quite evident, but emacs is for a particular subset of computer users, and a relatively small one in the grand scheme. While it has its own rigorous logic and an iron-clad design, I don’t think anyone would label is as intuitive in any modern sense without qualification. There’s a steep learning curve, by any measure. But what does that mean?

我想我已经相当清楚地表明了这一点,但 emacs 是为特定子集的计算机用户设计的,而且在整体范围内相对较小。尽管它有自己的严谨逻辑和坚不可摧的设计,但我认为如果没有限定条件,没有人会将其标记为现代意义上的直观。无论如何,它的学习曲线都很陡峭。但这意味着什么呢?

There are multiple factors. There’s the obstacle of learning how emacs does things — the modes and the buffers, the windows and the mode-line and the mini-buffer, the modular and extensible nature of everything, and its own jargon and mental model about the mark and the region, killing and yanking, local versus global modes, and all of it. It all makes sense, and you can just sit down with the manual (all 750+ pages of it, without any screenshots) and enjoy the journey, if that’s your thing. In fact, whether you want to read the manual is a decent litmus test of whether or not you’ll get along with emacs. Manual-readers will do well here.

有多个因素。首先是学习 emacs 如何运作的障碍——模式、缓冲区、窗口、模式行和迷你缓冲区,所有事物的模块化和可扩展性,以及它自己的术语和关于标记和区域、删除和粘贴、局部与全局模式等的思维模型。这一切都有道理,如果你愿意,可以坐下来阅读手册(全部 750 多页,没有任何截图),并享受这段旅程。事实上,你是否想阅读手册是一个不错的试金石,用以判断你是否能与 emacs 相处。喜欢阅读手册的人在这里会做得很好。

Then there’s the obstacle of physically adapting to the wholly keyboard-driven interface, and also the chorded and sequential nature of command input. I think your background on computers in general will be a deciding factor regarding how surmountable this is. I drive my computers via the keyboard alone whenever possible, and I have a catalogue of keyboard shortcuts rattling around my head, and I design and implement mechanical keyboard layouts for fun. All three of the clauses in the previous sentence included the word ‘keyboard’, for god’s sake. The venn overlap here is just a single big circle. But that may not be true for you, and you should be honest with yourself about that when you’re going in, because otherwise it’s going to feel like trying to translate a foreign language you don’t know, or Flying A Commercial Airliner For Dummies.

然后还有适应完全由键盘驱动的界面和命令输入的音阶和弦性质这一物理障碍。我认为你整体的计算机背景将决定这一障碍是否可以克服。只要有可能,我都是通过键盘操作我的计算机,我头脑中有一系列键盘快捷键,并且为了乐趣设计和实现机械键盘布局。前一句话中的三个子句都包含了“键盘”这个词,拜托。这里的交集只是一个大的圆圈。但这可能不适用于你,在你开始之前,你应该对自己诚实,否则它将感觉像尝试翻译一种你不懂的外语,或者像为《傻瓜》系列编写飞行 A 型商用飞机指南。

And finally there’s the double-edged sword of boundless customisation and configuration: the buck stops with you, because unless you just install it and then leave it the hell alone (in which case, why bother?), it’s really your software, and you can break it in fascinating ways, and then you have to fix it. There’s also the infinite time-sink of eternal tweaking and finessing of its ever-expanding functionality. The rabbit hole goes deep, and you’ll fall into it virtually immediately.

最后还有无限定制和配置这把双刃剑:责任最终在你,因为除非你只是安装它然后任其不管(那样的话,何必费心呢?),它才是你的软件,你可以用各种有趣的方式把它搞坏,然后你不得不去修复它。还有无尽的时间会被投入到对其不断扩展的功能的持续调整和优化中。兔子洞很深,你几乎会立刻掉进去。

If that all sounds horrible, then congratulations on being part of the sane super-majority. There are a great many polished GUI editors and IDEs to choose from, and you’ll be very happy with any of them. 如果这一切听起来很糟糕,那么恭喜你成为理智的绝大多数人中的一员。有许许多多精良的 GUI 编辑器和 IDE 可供选择,你用任何一个都会非常满意。

If, however, what I’ve described sounds super great and incredibly exciting, then you’re weird and you have control issues, and you’re probably a chronic procrastinator, and you’re maybe in the middle of some kind of mental health issue where you need to deep-dive into something complicated as a kind of avoidance reaction, and you are exactly like me. You’re going to absolutely love it. You’ll feel so seen.

然而,如果我描述的这一切听起来超级棒、令人兴奋无比,那么你就是个怪人,你有控制欲问题,你很可能是个慢性拖延症患者,也许你正处于某种心理健康问题的中,需要深入探索某个复杂事物作为逃避反应,你就是和我一样的人。你会绝对爱上它。你会感觉被完全理解。

In fact, you should install emacs right now, start configuring, and you’ll see what I mean. I’m going to stop talking so you can do that. Let me know what happens. We should totally talk about it!

事实上,你应该现在就安装 emacs,开始配置,你就会明白我的意思。我要停止说话,让你去做。告诉我发生了什么。我们绝对应该谈谈!

8 个赞

写得很好呀。深有同感。

把摄像头关关(

这个感觉没必要,因为手册的内容太多且大部分内容初学者实际都用不到,现在有ai了,可以很快就能入门,不会被什么基本问题卡住。 我有时感觉原手册并不适合初学者入门用,可以入门了以后在回来慢慢看,作为进阶

其实 Xah Lee 的线上教程就挺不错的, 例子丰富。

emacs 初学者不一定是编程的初学者,有一定编程经验的人读官方手册是学习 emacs&elisp 最快速、最准确的方式,时间有限的话,注意详略得当就行。我现在偶尔翻翻手册,还是能从中发现宝藏。

网络上许多介绍可能比不上手册的简单几句话精确、更容易让人理解。一手资料的价值就体现在这里。没那么多时间,倒是不必通读,对某个概念感兴趣或有困惑,直接找到手册对应的部分来读就是了。有的时候看似慢,其实是快的,因为少走了许多弯路。

1 个赞

我觉得作者这一段的观察相当的准确且重要。

”开箱即用” VS “自由定制”

“一切都是可定制的” 带来 “提升自己” 的同时也会让使用者 “陷入困境“,这便是自由的代价。如果插件的开发者没有提供合适的默认值,使用者就需要许多的学习成本来首先了解各个配置项的含义,然后才能很好的使用插件。这种极度自由的配置与其他软件的 “开箱即用” 对比,需要为 “emacs学习曲线陡峭“ 的观点负大部分责任。

但 “开箱即用” 的局限性是明显的:它让用户个性化的偏好变得不可能。用户只能按照开发者的预设的方式来使用功能,或者它可以提供一些简单的配置选项,但无法做到 emacs 那样深度的定制。所以,”开箱即用“ 是否好用非常考验开发者的水平:即该功能如何设计是符合大多数用户的需求和使用习惯的,在减少用户学习成本和心智负担的同时,又很好的满足了功能需求。

”开箱即用” 是可以漂亮的完成特定功能的工具,上手容易,但你几乎很难深入其内部结构,并且工具坏了还得找专门的人去维修。而 emacs 的 “自由定制“ 更像是暴露在外的各种机械结构:链条,齿轮…,你得先知道如何组合和调整它们才能使用,而一旦你学会了这些知识,就可以用它们来打造不局限于特定功能的工具。

如果可以话,作为一个普通用户,两者我都不想要;或者反过来说,两者我都想要。当我还是一个初学者时,我希望工具提供了针对不同场景的开箱即用的功能,它可以满足我绝大部分的需求;随着我经验渐长,有了些更个性的想法,我希望工具也能够提供足够自由的定制供我玩耍。

开箱即用的编辑器几乎做不到足够自由的定制,因为底层模型设计的不够通用(或者商业考虑等原因),它不可能将所有的底层API都暴露给用户进行定制。但 emacs 却完全有可能做到足够省心的开箱即用,但现状却不如人意。

何谓良好的"开箱即用"

我觉得 emacs 插件开箱即用不尽如人意的主要原因是:长期使用 emacs 的用户很多时候也是插件的开发者,即使没有写过插件,至少也写过一些 elisp 来定制功能。这样写出来的插件很多时候是带了“开发者”的视角的,缺少了一些“使用者”的视角。这导致的问题是:有些我们觉得理所当然的设计和交互方式可能对新手并不直观。

良好的"开箱即用"应当可以让用户以尽可能小的代价来达到目的。对于开发者来说就是要将复杂性封装在软件内部,并提供给用户简洁好用的抽象。这种抽象指的是满足不同场景功能的命令、一个直观的操作界面 或 良好的错误提示和建议,甚至是自动化的错误处理等等。

还有一个很重要的因素:默认值。正如作者提到的,默认值需要精心挑选!“开箱即用”意味着用户在没有进行配置或只进行了极少的必要配置时,就可以获得良好的使用体验,这对底层模型及其默认值的挑选有极高的要求。

默认值和复合选项

设置一个默认值限定了软件的一种行为,而不同选项可能有不同的默认值,这样排列组合下来,就会表现为丰富的行为,如何组合对用户来说是头疼的问题。除了给单个选项设置良好的默认值,我觉得给多个选项的不同默认值进行组合是不错的idea。这种良好的组合就形成了开箱即用的不同的场景。

许多插件是只提供了选项含义,让用户来自己定制,用户需要花不少时间来了解不同选项的含义和不同选项组合的行为,这一点都不开箱即用。插件的开发者是对所有选项最了解的人,如果能够预设一些良好的选项的组合,并封装为一个新的复合选项并辅以合适的命名,那么对于使用者就大大的减少了需要了解的选项的个数。如果这些预设的组合设置的足够好,可以覆盖大多数的场景,用户便不需要将其拆开进行更细致的配置就可以获得极好的使用体验。这便是默认值和复合选项的魅力!

一个具体例子

本着遵循前文核心思想的原则,可以把“抽象的表述”理解为一个"选项",那么“用户对抽象文本的具体理解”就是一个"默认值",那么我当然应该提供一个具体的例子作为开箱即用的“默认值”来降低阅读者的理解负担。

为了开发ETML,最近在阅读CSS的文档,我发现默认值和复合选项的设置在CSS中是广泛应用的。比如单独设置一个 border 属性,其实是设置了 border-width, border-style, border-color 这些子属性,而这些子属性又可以拆分为四个不同方向的子属性 border-left-width, border-left-style, border-left-color… 这样的复合选项的层层封装,让用户在非必要的情况下不必每次都去设置最底层的"具体的特定方向的边框的特定属性的值"。

还有一个例子,我在开发 etml-scroll-bar.el 的时候,为滚动条定义了如下的模型:

etml-scroll-bar 模型
(defclass etml-scroll-bar ()
  ((track-height
    :initarg :thumb-height :initform 1
    :documentation "滚动条轨道高度,根据 content-linum,content-height 计算得到")
   (track-color
    :initarg :track-color :initform nil
    :documentation "滚动条轨道的颜色,仅作用于 padding 部分")
   (track-left-padding
    :initarg: :track-left-padding :initform 0
    :documentation "滚动条轨道的左 padding 像素")
   (track-right-padding
    :initarg: :track-right-padding :initform 0
    :documentation "滚动条轨道的右 padding 像素")
   (track-left-margin
    :initarg :track-left-margin :initform 0
    :documentation "滚动条轨道的左 margin 像素")
   (track-right-margin
    :initarg :track-right-margin :initform 0
    :documentation "滚动条轨道的右 margin 像素")
   (track-left-border-pixel
    :initarg :track-left-border-pixel :initform 0
    :documentation "滚动条轨道左边的边框像素宽度")
   (track-right-border-pixel
    :initarg :track-right-border-pixel :initform 0
    :documentation "滚动条轨道右边的边框像素宽度")
   (track-left-border-color
    :initarg :track-left-border-color :initform nil
    :documentation "滚动条轨道左边的边框颜色")
   (track-right-border-color
    :initarg :track-right-border-color :initform nil
    :documentation "滚动条轨道右边的边框颜色")
   (thumb-offset
    :initarg :thumb-offset :initform 0 :documentation "滚动条初始偏移量")
   (thumb-height
    :initarg :thumb-height :initform 1
    :documentation "滚动条高度,根据 content-linum,content-height 计算得到")
   (thumb-pixel :initarg :thumb-pixel :initform 2
                :documentation "滚动条滑块像素宽度")
   (thumb-border :initarg :thumb-border :initform nil
                 :documentation "滚动条滑块的边框,nil 或颜色")
   (thumb-color :initarg :thumb-color :initform nil
                :documentation "滚动条滑块颜色"))
  "滚动条模型")

如果你对浏览器滚动条的实现不是很了解,自己去实例化这个模型来定义的滚动条可能会比较困难,因为需要先了解(滚动条、轨道等)每个字段的含义和组合之后的效果。但是我会预设一些默认值的组合来命令为不同的风格的滚动条。用户只需要选择更加上层模型中定义不同风格滚动条字段的值就可以了,可能这些风格的滚动条也会暴露几个字段允许用户做一些简单的定制,但是比起设置上面这十几个字段可简单太多了。

总结

总结起来,我觉好的设计应该是对于不同层次的使用者都能有好的体验。简单有简单的用法,复杂有复杂的用法。emacs 已经具备了复杂的能力,如何让它变得"简单"就显得很重要。毕竟作为开发者,不可能只使用自己写的插件,在使用别人插件的时候,也希望上手能够容易一些;而对于刚刚接触 emacs 的新手用户,前期的简单就决定了是否会继续使用 emacs。

相较于纯文本的环境,现代用户更习惯于有一个良好布局和交互的界面来使用各种功能,因为它简单、直观。如果 emacs 中的插件都是以类似桌面或手机app、网页的方式呈现出来的,我相信未来 emacs 的学习曲线会平缓很多。这就是我开发 ETAF 的原因。

6 个赞

我觉得不会, 习惯了GUI程序、图形化支持不好、学习曲线陡… 我一直都感觉这些只是不想用emacs的人随口找的理由, 就像你开发了一个程序, 他们会说要写好操作说明, 你写好操作说明, 他们说这个没有截图讲解, 你把操作说明都做成图片, 他们说图片太多加载缓慢, 你做到了图文并茂, 他们说这个文档太长了,要简短,你做简短了,他们说文档最好有交互性… 总之,就是能有各种理由,见多了也就见怪不怪

4 个赞