jiacai2050 / ideas

Think more
https://github.com/jiacai2050/ideas/issues
29 stars 2 forks source link

Emacs 29 is nigh! What can we expect? #52

Open jiacai2050 opened 1 year ago

jiacai2050 commented 1 year ago

https://blog.phundrak.com/emacs-29-what-can-we-expect/

It was announced a couple of hours ago, Emacs 29’s branch is now cut from the master branch! This means the emacs-29 branch will from now no longer receive any new feature, but only bug fixes.

So, what’s new with this new major release? I skimmed over the NEWS file, and here are the changes which I find interesting and even exciting for some.

Article updated on November 30th at 13:15 UTC

Major features

A couple of major improvements will be most likely present, here are the ones that stand out the most for me.

Eglot is now part of Emacs core

During the last couple of years, LSP has given text editors incredible capabilities, giving them IDE-like features relatively easily. Aside from Elisp development, most of the code I write is now done with the help of an LSP server, running along Emacs and analyzing my code, suggesting and performing changes and actions for me.

Several integrations of LSP exist for Emacs, such as LSP Mode, Eglot, and lsp-bridge. Among the three, Eglot is now part of Emacs core! No longer do you need to install a package, simply register an LSP server and autocompletion, documentation, error detection, and other features will become available right away!

I must admit I don’t really know Eglot, I personally use LSP Mode, but with this addition to Emacs core, I might attempt the switch.

Tree-Sitter is also part of Emacs core

In case you didn’t know, Emacs’ current syntax highlighting is currently based on a system of regexes. Although it is not the worst thing to use, it’s not the best either, and it can become quite slow on larger files.

Tree-Sitter parses programming languages based into a concrete syntax tree. From there, not only can syntax highlighting can be done at high speed, but a much deeper analysis of the code is possible and actions such as syntax manipulation can also be achieved since the syntax tree itself is available as an object which can be manipulated!

In case you want some more information on Tree-Sitter itself, you can check out the official Tree-Sitter website, or you can even check this talk out given by Tree-Sitter’s creator, Max Brunsfeld.

Well, this is now a native solution in Emacs! Currently, Emacs’ Tree-Sitter supports the current major modes :

Tree-Sitter also holds for now a special status in the new emacs-29 branch since new features can still be added to it, as its merging with the master branch is still recent. So we might see the list of major modes for Emacs get a bit longer yet, especially considering Tree-Sitter tries to make adding new languages relatively easy.

If you can’t wait to test Tree-Sitter, there is already another package available for Emacs you can use right now. Just be aware this is not the same package as the one that got integrated into Emacs.

Install packages from source with package.el

If you use Straight, you might be familiar with installing packages directly from their Git repository. Well, good news, it is now possible to install packages from Git using Emacs’ built-in packaging system package.el! It can be done with the new function package-vc-install, and packages installed that way can be updated with package-vc-update or package-vc-update-all.

On the topic of package.el, there is also the new function package-report-bug which allows Emacs users to report bugs to the developers of a package directly from Emacs! Be aware though, it only works for packages installed through package.el. Since I’m a use-package and straight.el user, there is no package listed when I invoke the command.

Org mode 9.6

As confirmed by one of org-mode maintainers Bastien Guerry on a French-speaking Emacs mailing list, Org 9.6 is set to be part of Emacs 29! I may try to write an article on this new release too, which is already available on GNU ELPA!

use-package in Emacs core

It has also been confirmed on the Emacs development mailing list that use-package, an awesome package manager, is set to be part of Emacs 29, although it initially wasn’t included in the emacs-29 branch.

Pure GTK Emacs is here for Wayland!

One of the major issues Emacs had on Linux was its dependency on Xorg when running in GUI mode. When running Xorg, it’s not really an issue, but Wayland has become more and more common during the last years, and even with the existence of XWayland, this became an annoyance.

Well, fear not, for pure GTK Emacs is here! It can now be built Xorg-free and run natively in Wayland!

Be aware though that Wayland is basically the only use-case for pure GTK Emacs. If you don’t use Wayland, Emacs will display a warning message, as it will most likely cause issues if you are running Xorg. In my case, I sometimes see some ghost text when the content of a buffer updates (I still need pure GTK though, since I alternate between Xorg and Wayland).

Compile EmacsLisp files ahead of time

With Emacs 28 came the ability to natively compile EmacsLisp if your Emacs was built with the ability to do so, using GCC’s Just In Time library. This results in quite the impressive boost in performance, which made Emacs much snappier than it was before. The only issue I had was Emacs would only compile its EmacsLisp files when they were loaded for the first time.

This is no longer the case! If you now compile Emacs with --with-native-compilation=aot, Emacs’ native EmacsLisp files will be natively compiled along with Emacs itself! Be aware though, it can be slow on most machines, so the time you save by not compiling these files when launching Emacs for the first time is basically transferred to when compiling Emacs itself. Is it worth your time? In my case, I would say yes, because when I compile Emacs, I’m generally not in a hurry. But in your case? Well, test it out and see for yourself.

Native access to SQLite databases

Emacs can now be built with native support for SQLite and the sqlite3 library. In fact, this is now a default behaviour, since you need to pass --without-sqlite3 to Emacs’ build configuration script in order to prevent it.

This comes with a new sqlite-mode which allows you to explore SQLite databases within Emacs and to interact with them. Check out the sqlite-mode-open-file function!

HaikuOS support

For all three HaikuOS users out there, good news, you now have access to Emacs! (In all seriousness, I should check out HaikuOS one day)

Moreover, it also supports an optional window-system port to Haiku with --with-be-app. Be aware, you will need the Haiku Application Kit development headers and a C++ compiler. Otherwise, Emacs will only run in the terminal. If you want to also add Cairo to the mix, you can add --with-be-cairo.

New major mode for C

csharp-mode is now a native major mode for Emacs and is based on cc-mode.

Minor features

It’s easier to use Emacs in scripts!

If you like to write scripts and especially writing Lisp scripts, Emacs now supports the option -x in order to execute scripts written in EmacsLisp. When executing such a script with #!/usr/bin/emacs -x as its shebang, Emacs will not read its init file (like with -Q) and will instead execute the Elisp code right away and return the last value to the caller of the script (most likely the shell you called the script from).

TRAMP natively supports Docker, Podman, and Kubernetes

Three new connections are now available for TRAMP:

You will now be able to access your containerized environment right from Emacs without the need to write custom code.

Custom user directory

It is now easier to launch custom Emacs profiles without the need of tools such as chemacs2 with the addition of the flag --init-directory. This can set to any directory Emacs’ user-emacs-directory which includes the init.el which comes along with it. Yet another reason for me not to use a .emacs file, but the init.el file instead.

Support for Webp images

For quite some time, Emacs has been able to display images, but not webp yet. Well, this is now fixed! And in fact, support for webp images became the default behaviour, since you need to pass --without-webp to Emacs’ configuration script to disable webp support.

C++ mode now supports the C++20 standard

Yep. There’s nothing more to say, really. Happy coding!

Better handling of .pdmp files

Emacs has had for a few version the ability to dump its state into a pdmp file for faster startup time. Well now, when creating such a file, it will include in its name a fingerprint of its current state, although it will still prioritize an emacs.pdmp file if it exists.

Better mouse and touchpad support

Emacs now uses XInput 2, which enables Emacs to support more input events, such as touchpad events. For instance, by default, a pinch gesture on a touchpad increases or decreases the text size of the current buffer. This is thanks to the new event pinch, which comes along with touch-end.

Unicode 15.0 and emojis

Emacs now supports Unicode 15.0, which is currently the latest Unicode version. Although this is not directly related, quite a few new emoji-related features have been introduced. The new prefix C-x 8 e now leads to a few new commands related to emojis:

C-x 8 e e or C-x 8 e i

Insert an emoji (emoji-insert)

C-x 8 e s

Search an emoji (emoji-search)

C-x 8 e l

List all emojis in a new buffer (emoji-list)

C-x 8 e r

Insert a recently inserted emoji (emoji-recent)

C-x 8 e d

Describe an emoji (emoji-describe)

C-x 8 e + and C-x 8 e -

Increase and decrease the size of any character, but especially emojis (emoji-zoom-increase and emoji-zoom-decrease respectively)

There is also the new input method emoji which allows you to type for instance :⁣grin: in order to get the emoji 😁.

True background transparency

Up until recently, if you wanted transparency with Emacs, you had no choice but to make the whole frame transparent, including text and images.

Thanks to the frame parameter alpha-background and its related alphaBackground X resource, it is now possible to set transparency only for the frame’s background without affecting any of the other elements on screen.

WebKit inspector in Emacs’ WebKit widget browser

You can now access the WebKit inspector when using the WebKit widget browser in Emacs, given you are using a version of Emacs which has been compiled with it. I wish there was a keybinding or at leas a function for it, but apparently you can only open it with a right click and select Inspect Element. Still nice to have.

Some news for Windows

Although it has been available for Linux users since Emacs 26.1, Windows finally has access to double-buffering to reduce display flicker. If you wish to disable it, you can set the frame parameter inhibit-double-buffering to nil.

Emacs also follows Windows’ dark mode with Windows 10 (version 1809) and onwards.

Emacs also now uses Windows’ native API to render images. This includes BMP, GIF, JPEG, PNG, and TIFF images. Other formats, however, still rely on other dependencies and libraries to properly work, such as Webp images.

What’s next?

With Emacs 29 being cut, development on the master branch will now go towards Emacs 30. Is there anything we can expect yet?

It’s still very early to say, most stable features merged into master went to Emacs 29, and only the feature/pkg and feature/improved-lock-narrowing branches seem to have received commits less than a week prior to the day of writing this, and I do not know the status of other branches that received commits during the past few weeks such as feature/package+vc or feature/eglot2emacs (which I assume both got merged).

~However, there are currently talks about including use-package into Emacs! I’m a bit disappointed it won’t make it into Emacs 29, but progress is being made on scratch/use-package, and you can always check the mailing list to check its status such as here.~ Update: Rejoice! As mentioned above, use-package is actually set to land in Emacs 29!

jiacai2050 commented 1 year ago

几个小时前宣布,Emacs 29 的分支现在从 master 分支中切掉了!这意味着该emacs-29分支从现在起将不再接收任何新功能,而只会接收错误修复。

那么,这个新的主要版本有什么新内容?我浏览了NEWS文件,这里有一些我觉得有趣甚至令人兴奋的变化。

文章于 11 月 30 日 13:15 UTC 更新

主要特点

很可能会出现一些重大改进,以下是对我来说最突出的改进。

Eglot 现在是 Emacs 核心的一部分

在过去几年中,LSP 为文本编辑器提供了难以置信的功能,相对容易地为它们提供类似 IDE 的功能。除了 Elisp 开发,我编写的大部分代码现在都是在 LSP 服务器的帮助下完成的,它与 Emacs 一起运行并分析我的代码,为我建议和执行更改和操作。

Emacs 存在多个 LSP 集成,例如LSP ModeEglotlsp-bridge。在这三者中,Eglot 现在是 Emacs 核心的一部分!您不再需要安装包,只需注册一个 LSP 服务器,自动完成、文档、错误检测和其他功能将立即可用!

我必须承认我并不真正了解 Eglot,我个人使用 LSP 模式,但是随着 Emacs 核心的添加,我可能会尝试切换。

Tree-Sitter 也是 Emacs 核心的一部分

如果您不知道,Emacs 当前的语法突出显示目前是基于正则表达式系统。虽然这不是_最糟糕_的使用方式,但也不是最好的,而且在处理较大的文件时会变得相当慢。

Tree-Sitter 将编程语言解析为具体的语法树。从那里,不仅可以高速完成语法高亮显示,而且可以对代码进行更深入的分析,并且还可以实现语法操作等操作,因为语法树本身可以作为可以操作的对象使用!

如果您想了解有关 Tree-Sitter 本身的更多信息,可以查看官方 Tree-Sitter 网站,或者您甚至可以查看 Tree-Sitter 的创建者 Max Brunsfeld 发表的演讲。

好吧,这现在是 Emacs 中的原生解决方案!目前,Emacs 的 Tree-Sitter 支持目前主要的模式:

Tree-Sitter 目前在新分支中也拥有特殊地位,emacs-29因为新功能仍然可以添加到它,因为它与 master 分支的合并仍然是最近的。所以我们可能会看到 Emacs 的主要模式列表变得更长一些,特别是考虑到 Tree-Sitter 试图使添加新语言相对容易。

如果您迫不及待地想测试 Tree-Sitter,现在已经有另一个适用于 Emacs 的软件包可供您使用。请注意,这与集成到 Emacs 中的包不同。

从源安装包package.el

如果您使用Straight,您可能熟悉直接从他们的 Git 存储库安装包。嗯,好消息,现在可以使用 Emacs 的内置打包系统从 Git 安装包了package.el!可以使用 new 函数来完成package-vc-install,并且可以使用package-vc-update或更新以这种方式安装的包package-vc-update-all

关于 的主题package.el,还有一个新功能package-report-bug,允许 Emacs 用户直接从 Emacs 向包的开发人员报告错误!但请注意,它仅适用于通过package.el. 由于我是use-packageandstraight.el用户,因此在我调用该命令时没有列出包。

组织模式 9.6

正如 org-mode 维护者之一Bastien Guerry法语 Emacs 邮件列表中确认的那样,Org 9.6 将成为 Emacs 29 的一部分!我也可能会尝试写一篇关于这个新版本的文章,它已经在 GNU ELPA 上可用

Emacs 核心中的使用包

在Emacs 开发邮件列表上也已确认,use-package一个很棒的包管理器将成为 Emacs 29 的一部分,尽管它最初并未包含在该emacs-29分支中。

纯 GTK Emacs 为 Wayland 而来!

Emacs 在 Linux 上的主要问题之一是它在 GUI 模式下运行时对 Xorg 的依赖。运行 Xorg 时,这不是真正的问题,但 Wayland 在过去几年变得越来越普遍,即使有 XWayland 的存在,这也成为一个烦恼。

好吧,不要害怕,因为纯 GTK Emacs 就在这里!它现在可以在无 Xorg 的情况下构建并在 Wayland 中本地运行!

请注意,Wayland 基本上是纯 GTK Emacs 的唯一用例。如果您不使用 Wayland,Emacs 将显示一条警告消息,因为如果您运行的是 Xorg,它很可能会导致问题。在我的例子中,当缓冲区的内容更新时,我有时会看到一些幻影文本(尽管我仍然需要纯 GTK,因为我在 Xorg 和 Wayland 之间交替)。

提前编译 EmacsLisp 文件

如果您的 Emacs 是使用 GCC 的 Just In Time 库构建的,那么 Emacs 28 可以原生编译 EmacsLisp。这导致了令人印象深刻的性能提升,这使得 Emacs 比以前更加敏捷。我遇到的唯一问题是 Emacs 只会在第一次加载 EmacsLisp 文件时编译它们。

这已不再是这种情况!如果您现在使用 编译 Emacs --with-native-compilation=aot,Emacs 的本机 EmacsLisp 文件将与 Emacs 本身一起本机编译!但请注意,它在大多数机器上可能会很慢,因此您在第一次启动 Emacs 时不编译这些文件而节省的时间基本上会转移到编译 Emacs 本身时。值得你花时间吗?就我而言,我会说是,因为当我编译 Emacs 时,我通常并不着急。但在你的情况下?好吧,自己测试一下看看。

本地访问 SQLite 数据库

现在可以使用对 SQLite 和 sqlite3 库的本机支持来构建 Emacs。事实上,这是现在的默认行为,因为您需要传递--without-sqlite3给 Emacs 的构建配置脚本以防止它发生。

这是一个新sqlite-mode功能,它允许您在 Emacs 中探索 SQLite 数据库并与它们交互。看看sqlite-mode-open-file功能吧!

HaikuOS 支持

对于所有三个 HaikuOS 用户来说,好消息是,您现在可以使用 Emacs 了!(说真的,我应该有一天去看看 HaikuOS)

此外,它还支持一个可选的窗口系统端口到 Haiku,带有--with-be-app. 请注意,您将需要 Haiku Application Kit 开发头文件和 C++ 编译器。否则,Emacs 只会在终端中运行。如果您还想将 Cairo 添加到组合中,您可以添加--with-be-cairo.

C# 的新主要模式

csharp-mode现在是 Emacs 的原生主要模式,并且基于cc-mode.

次要特征

在脚本中使用 Emacs 更容易!

如果您喜欢编写脚本,尤其是编写 Lisp 脚本,Emacs 现在支持该选项-x以执行用 EmacsLisp 编写的脚本。当使用 as shebang 执行这样的脚本时#!/usr/bin/emacs -x,Emacs 不会读取它的 init 文件(如 with -Q),而是会立即执行 Elisp 代码并将最后一个值返回给脚本的调用者(很可能是您调用脚本的 shell从)。

TRAMP 原生支持 Docker、Podman 和 Kubernetes

三个新连接现在可用于 TRAMP:

您现在可以直接从 Emacs 访问您的容器化环境,而无需编写自定义代码。

自定义用户目录

现在可以更轻松地启动自定义 Emacs 配置文件,而无需使用chemacs2等工具并添加 flag --init-directory。这可以设置为 Emacs 的任何目录,user-emacs-directory其中包括init.el随附的目录。.emacs我不使用文件,而是使用文件的另一个原因init.el

支持 Webp 图片

很长一段时间以来,Emacs 已经能够显示图像,但 webp 还不行。好吧,现在已经解决了!事实上,对 webp 图像的支持已成为默认行为,因为您需要传递--without-webp给 Emacs 的配置脚本以禁用 webp 支持。

C++ 模式现在支持 C++20 标准

是的。没什么好说的,真的。编码愉快!

更好地处理.pdmp文件

Emacs 有几个版本能够将其状态转储到pdmp文件中以加快启动时间。那么现在,当创建这样一个文件时,它会在其名称中包含其当前状态的指纹,尽管它仍然会优先考虑一个emacs.pdmp文件(如果存在)。

更好的鼠标和触摸板支持

Emacs 现在使用 XInput 2,它使 Emacs 能够支持更多的输入事件,例如触摸板事件。例如,默认情况下,触摸板上的捏合手势会增大或减小当前缓冲区的文本大小。这要归功于pinch伴随touch-end.

Unicode 15.0 和表情符号

Emacs 现在支持Unicode 15.0,这是目前最新的 Unicode 版本。虽然这没有直接关系,但已经引入了很多与表情符号相关的新功能。新前缀C-x 8 e现在会导致一些与表情符号相关的新命令:

C-x 8 e e或者C-x 8 e i

插入表情符号 ( emoji-insert)

C-x 8 e s

搜索表情符号 ( emoji-search)

C-x 8 e l

列出新缓冲区中的所有表情符号 ( emoji-list)

C-x 8 e r

插入最近插入的表情符号 ( emoji-recent)

C-x 8 e d

描述一个表情符号 ( emoji-describe)

C-x 8 e +C-x 8 e -

增加和减少任何字符的大小,尤其是表情符号(emoji-zoom-increaseemoji-zoom-decrease分别)

还有新的输入法emoji,允许您输入例如:⁣grin:以获得表情符号😁。

真正的背景透明度

直到最近,如果您想使用 Emacs 实现透明度,您别无选择,只能使整个框架透明,包括文本和图像。

由于 frame 参数alpha-background及其相关的alphaBackgroundX 资源,现在可以只为框架的背景设置透明度,而不会影响屏幕上的任何其他元素。

Emacs 的 WebKit 小部件浏览器中的 WebKit 检查器

在 Emacs 中使用 WebKit 小部件浏览器时,您现在可以访问 WebKit 检查器,前提是您使用的 Emacs 版本是用它编译的。我希望它有一个键绑定或至少一个功能,但显然你只能通过右键单击打开它并选择Inspect Element。还是很高兴拥有。

Windows 的一些新闻

尽管从 Emacs 26.1 开始,Linux 用户就可以使用它,但 Windows 终于可以使用双缓冲来减少显示闪烁。如果你想禁用它,你可以将 frame 参数设置inhibit-double-bufferingnil

Emacs 在 Windows 10(版本 1809)及更高版本中也遵循 Windows 的暗模式。

Emacs 现在还使用 Windows 的本机 API 来呈现图像。这包括 BMP、GIF、JPEG、PNG 和 TIFF 图像。然而,其他格式仍然依赖其他依赖项和库才能正常工作,例如 Webp 图像。

下一步是什么?

随着 Emacs 29 被削减,master 分支上的开发现在将转向 Emacs 30。有什么我们可以期待的吗?

现在说还为时过早,大多数合并到 master 中的稳定功能都去了 Emacs 29,而且只有feature/pkgfeature/improved-lock-narrowing分支似乎在写这篇文章的前一周不到收到提交,我不知道其他分支的状态在过去几周内收到了提交,例如feature/package+vcor feature/eglot2emacs(我假设两者都已合并)。

~然而,目前有关于包含use-package到 Emacs 中的讨论!我有点失望它不会进入 Emacs 29,但正在取得进展scratch/use-package,您可以随时查看邮件列表以检查其状态,例如此处。~ 更新:高兴!如上所述,use-package实际上是设置在 Emacs 29 中登陆!