My Emacs 31 contributions
My Emacs 31 contributions
对我来说,向 Emacs 上游提交代码一直感觉有些遥不可及,所以我拖延了很长一段时间。也许最大的障碍是完成向自由软件基金会(FSF)转让版权的流程,这确实感觉有点过时(需要下载、签署并寄回 PDF)且缓慢(主要是等待电子邮件回复),不过话说回来,我对此只有同情。开源项目在可持续性方面非常棘手。作为消费者,我们通常既喜欢“自由”的免费,也喜欢“免费啤酒”式的免费,但这两者都无法支付账单。我们希望有公司介入资助这些项目,但这很少发生。结果是,大多数开源项目(即使是受欢迎的项目)都处于饥饿状态,由志愿者免费工作。
For me, landing changes in Emacs upstream always felt somewhat out of reach, so I kinda postponed it for a long while. Perhaps the biggest hurdle was getting over the process to assign copyright to the Free Software Foundation, which does feel a bit archaic (download, sign, and return a PDF) and slow (mostly waiting for an email response), though hey, I have nothing but sympathy. Open source is unsustainably tricky. As consumers, we often like free as in freedom and free as in beer, but neither pay the bills. We hope some company steps in to fund these projects, but that rarely happens. As a result, most open source projects are starved (even popular ones), run by volunteers working for free.
总而言之,如果 Emacs 上游的贡献/入职流程看起来不够理想,请多包涵。整个项目主要依靠无偿贡献者的血汗和泪水来维持。如果可以的话,请资助你所依赖的维护者(或者更好的是,让你所在的雇主这样做)。如果你一直在考虑向 Emacs 上游贡献代码,不要像我一样拖延,试一试吧。与典型的 GitHub 拉取请求流程相比,你的第一次 Emacs 贡献可能会让你感到有些畏惧和陈旧,但隧道尽头有一道可爱的微光。要知道,Emacs 已经存在 50 年了。很少有软件项目能活这么久。能为一个拥有如此丰富历史的项目贡献代码,真是一种享受!但我离题了……让我们开始吧。
All that is to say, if the upstream Emacs contribution/onboarding process seems less than ideal, cut it some slack. The project as a whole primarily runs on the blood, sweat, and tears of unpaid contributors. If you can, fund the maintainers you rely on (or better yet, get your employer to do so). If you’ve been thinking of contributing to Emacs upstream, don’t procrastinate like me and just give it a try. Compared to the typical GitHub pull-request process, your first Emacs contribution may feel a little daunting and dated, but there’s a lovely fuzzy light at the end of the tunnel. You see, Emacs has been around for 50 years. Very few software projects get to live this long. Landing contributions on a project with such a rich history is a real treat! But I digress… Let’s get moving.
一旦我克服了拖延症,我终于让一些小的贡献进入了主分支。感谢 Eli Zaretskii、Stefan Kangas 和 Gerd Möllmann 的帮助。从那时起,我热切地等待着它们正式进入稳定版本。Emacs 31 发布时包含了这些内容。
Once I got over procrastinating, I finally got a handful of small contributions landed on the master branch. Thank you, Eli Zaretskii, Stefan Kangas, and Gerd Möllmann, for your help. From then on, I eagerly waited for them to formally make it to a stable release. Emacs 31 shipped the lot.
隐藏 Dired 的绝对路径
我确实喜欢在这里或那里做一些视觉(和功能)上的调整,而 Dired 的一个调整感觉足够小,非常适合作为我的第一次 Emacs 贡献。考虑到这一点,我通过添加 dired-hide-details-hide-absolute-location 用户选项调整了 dired-hide-details-mode,该选项可以隐藏通常显示在 Dired 缓冲区顶部的目录绝对路径(bug#72272,提交记录)。更多信息请参阅我的《隐藏另一个细节》文章。
Hide Dired’s absolute location
I do enjoy a visual (and functional) tweak here and there, and a Dired tweak felt small enough to be the perfect candidate for my very first Emacs contribution. With that in mind, I tweaked dired-hide-details-mode by adding the dired-hide-details-hide-absolute-location user option, which hides the directory’s absolute path, typically displayed at the top of Dired buffers (bug#72272, commit). More on this in my Hide another detail post.
macOS 语音识别权限
有一次,我在尝试从我钟爱的 eshell 运行 macosrec 时遇到了困难。进程只是因为一个晦涩的 abort trap: 6 而崩溃,所以问题并不明显。事实证明,该工具需要授予一项操作系统权限,而该权限只有在宿主应用程序(Emacs)的 Info.plist 文件中包含相关描述时才能由其请求。从 31 版本开始,Emacs 在其 Info.plist 中包含了 NSSpeechRecognitionUsageDescription(bug#72827,提交记录)。
macOS speech recognition permission
At some point, I ran into a snag trying to run macosrec from my beloved eshell. The process just crashed with a cryptic abort trap: 6, so the issue wasn’t super obvious. It turned out the utility required granting an OS permission that can only be requested by the host app (Emacs) if it includes the relevant description in its Info.plist file. As of version 31, Emacs includes NSSpeechRecognitionUsageDescription in its Info.plist (bug#72827, commit).
发送到……(即 macOS 共享)
context-menu-mode 现在包含一个“发送到……”项目,可以将当前文件或选定区域的文本发送到外部应用程序或服务。你也可以直接调用 M-x send-to。在 macOS 上,它由原生的共享选择器驱动(我经常用它通过 AirDrop 将东西发送到我的 iPhone)。在其他平台上,它会回退到 shell-command-do-open(bug#76120,提交记录,后续修复)。这两个实现都接入了新的通用管道(send-to-handlers),因此你可以,例如,添加一个通过 Android 原生共享表单(android-browse-url 可以完成繁重的工作)或 Linux 上的 KDE Connect (kdeconnect-cli --share) 进行共享的处理程序。更多信息请参阅我的《Emacs 发送到(即 macOS 共享)合并到上游》文章。
Send to… (aka macOS sharing)
context-menu-mode now includes a “Send to…” item, enabling sending the current file(s) or region text to external apps or services. You can also invoke M-x send-to directly. On macOS, it’s powered by the native sharing picker (I use it frequently to AirDrop things to my iPhone). Elsewhere, it falls back to shell-command-do-open (bug#76120, commit, follow-up fix). These two implementations plug into new generic plumbing (send-to-handlers), so you could, for instance, add a handler sharing via Android’s native share sheet (android-browse-url can do the heavy lifting) or KDE Connect on Linux (kdeconnect-cli —share). More in my Emacs send-to (aka macOS sharing) merged upstream post.
macOS 听写功能回归
Emacs 30 在迁移到 NSTextInputClient 时丢失了 macOS 听写功能。在 nsterm.m 中实现 selectedRange 后,该功能又回来了(bug#79070,提交记录)。随着如今 LLM/代理的流行,向 Emacs 缓冲区进行听写可能正是补充你 AI 工作流的绝佳方式。我在我的《macOS 听写功能回归 Emacs(修复已合并)》文章中介绍了这一点。
macOS dictation is back
Emacs 30 lost macOS dictation when migrating to NSTextInputClient. Implementing selectedRange in nsterm.m brought it back (bug#79070, commit). With LLMs/agents being a thing these days, dictating into your Emacs buffer may be just the thing to complement your AI workflow. I covered this in my macOS dictation returns to Emacs (fix merged) post.
让一切可持续发展
你是否从我的任何上游更改或 Emacs 软件包中获得了价值?请考虑赞助以保持这项工作的持续进行。虽然我的补丁看起来相对简单,但有些补丁确实花费了相当大的努力才进入上游。我的 Emacs 工作不合你的胃口?没关系。如前所述,请转而赞助你所依赖的维护者。
Make it all sustainable
Are you getting value from any of my upstreamed changes or my Emacs packages? Please consider sponsoring to keep the work going. While my patches may seem relatively straightforward, some took quite a bit of effort to land upstream. My Emacs work not your cup of tea? No worries. As mentioned earlier, sponsor the maintainers you rely on instead.