What's in the Emacs newcomers-presets theme?

What’s in the Emacs newcomers-presets theme?

Emacs 的 newcomers-presets 主题里有什么?

[2026-08-31 Mon]: Added Emacs 31 mention. Changed code sample for flyspell-mode to flymake-mode. Thanks, jeenajeena! Emacs 31 (released Aug 2026) as well as development versions of Emacs after Feb 2026 includes a newcomers-presets theme that can be enabled from the splash screen or by using M-x load-theme RET newcomers-presets RET. (Not sure how to run that command? Start with the guided tour/tutorial or choose “Help - Tutorial” from the Emacs menu.) [2026-08-31 周一]:增加了关于 Emacs 31 的说明。将 flyspell-mode 的代码示例更改为 flymake-mode。感谢 jeenajeena!Emacs 31(2026 年 8 月发布)以及 2026 年 2 月之后的 Emacs 开发版本中包含了一个 newcomers-presets 主题,可以通过启动画面或使用 M-x load-theme RET newcomers-presets RET 来启用。(不确定如何运行该命令?请从引导教程开始,或在 Emacs 菜单中选择“Help - Tutorial”。)

Figure 1: Newcomer presets are on the splash screen. If you like it and want to make it automatically enabled in future Emacs sessions: Use M-x customize-themes. Select the checkbox next to newcomer-presets by either clicking on it or using TAB to navigate to it and then pressing RET. Click on or use RET to select Save Theme Settings. 图 1:启动画面上的新手预设。如果你喜欢它并希望在未来的 Emacs 会话中自动启用它:请使用 M-x customize-themes。通过点击或使用 TAB 键导航到 newcomer-presets 旁边的复选框并按 RET 键选中它。点击或使用 RET 键选择“Save Theme Settings”(保存主题设置)。

Figure 2: Saving the theme setting. I’m not sure if someone else has made notes on what it does yet, so I thought I’d put this together. Most Emacs newbies aren’t running the development version of Emacs at the moment, but it will eventually make its way into Emacs 31. I wonder if it might be a good idea to extract the theme as a package that people can use use-package on if they want. I am not entirely sure about using themes for this, but it’s worth an experiment. 图 2:保存主题设置。我不确定是否已经有人记录了它的具体功能,所以我决定整理一下。目前大多数 Emacs 新手并没有运行 Emacs 的开发版本,但它最终会进入 Emacs 31。我在想,如果能将这个主题提取为一个包,让人们可以根据需要使用 use-package 来加载,或许是个好主意。我不确定用主题来实现这一点是否完全合适,但这值得一试。

Here’s a list of what newcomers-presets includes. I’ll also include the corresponding Emacs Lisp in case you want to copy just that part, or you can also get it as copy-of-newcomers-presets.el. If you want to load it in your existing Emacs, you can add (load-file “path/to/copy-of-newcomers-presets.el”) to your InitFile. You can use C-h f (describe-function) or C-h v (describe-variable) to learn more about the functions or variables it changes. 以下是 newcomers-presets 所包含的内容列表。我还将附上相应的 Emacs Lisp 代码,以防你只想复制其中一部分,或者你也可以将其作为 copy-of-newcomers-presets.el 获取。如果你想在现有的 Emacs 中加载它,可以将 (load-file "path/to/copy-of-newcomers-presets.el") 添加到你的初始化文件中。你可以使用 C-h f (describe-function) 或 C-h v (describe-variable) 来了解它所更改的函数或变量的更多信息。

Editing and navigation

编辑与导航

When you select text by pressing C-SPC (set-mark-command) and then moving to the end of the text you want to select, and then you type, the new text replaces the selection. 当你通过按下 C-SPC (set-mark-command) 选中一段文本,移动到选区末尾并开始输入时,新输入的文本会替换掉选中的内容。

(setopt delete-selection-mode t)

Copying works better when copying between Emacs and other applications. 在 Emacs 和其他应用程序之间复制时,效果更好。

Equivalent: (setopt save-interprogram-paste-before-kill t) 等效于:(setopt save-interprogram-paste-before-kill t)

If you have a compatible spellchecker installed (Hunspell, Aspell, Ispell, or Enchant), Emacs will check your spelling and underline errors using flyspell-mode. You can use M-x ispell-change-dictionary to change the language if you have the appropriate dictionary installed. In code buffers, the spelling is checked in comments and strings. You can also use flyspell-goto-next-error (C-,) to go to the next misspelled word and flyspell-auto-correct-word (C-M-i) to fix it. 如果你安装了兼容的拼写检查器(Hunspell、Aspell、Ispell 或 Enchant),Emacs 将使用 flyspell-mode 检查你的拼写并为错误添加下划线。如果你安装了相应的词典,可以使用 M-x ispell-change-dictionary 来更改语言。在代码缓冲区中,拼写检查仅针对注释和字符串。你还可以使用 flyspell-goto-next-error (C-,) 跳转到下一个拼写错误的单词,并使用 flyspell-auto-correct-word (C-M-i) 进行修正。

(add-hook ‘text-mode-hook ‘flyspell-mode) (add-hook ‘prog-mode-hook ‘flyspell-prog-mode)

Imenu entries are automatically updated based on the structure of the current buffer or file (ex: outline headings, function names). You can list them with M-x imenu or add them to the menu bar with M-x imenu-add-to-menubar. Imenu 条目会根据当前缓冲区或文件的结构(例如:大纲标题、函数名)自动更新。你可以使用 M-x imenu 列出它们,或使用 M-x imenu-add-to-menubar 将其添加到菜单栏。

(setopt imenu-auto-rescan t)

When you visit a read-only file, it will be in view mode, so you can use SPC to scroll. This affects buffers for files that you don’t have permission to change as well as buffers that you make read-only using C-x C-q (read-only-mode). 当你访问只读文件时,它将处于查看模式(view mode),因此你可以使用空格键(SPC)进行滚动。这不仅适用于你没有权限修改的文件缓冲区,也适用于你通过 C-x C-q (read-only-mode) 手动设为只读的缓冲区。

(setopt view-read-only t)

Keyboard shortcuts

键盘快捷键

Some commands allow you to use just the last part of the keyboard shortcut in order to repeat them. 某些命令允许你仅使用键盘快捷键的最后一部分来重复执行它们。

(setopt repeat-mode t)

Appearance

外观

Scrolling happens more smoothly instead of jumping by character. 滚动更加平滑,而不是按字符跳跃。

(setq pixel-scroll-mode t)

Line numbers are shown in both text and code buffers. 在文本和代码缓冲区中都会显示行号。

(add-hook ‘prog-mode-hook ‘display-line-numbers-mode) (add-hook ‘text-mode-hook ‘display-line-numbers-mode)

Column numbers are shown in the mode line. 模式行(mode line)中会显示列号。

(setopt column-number-mode t)

If you change your system-wide fixed-width font, Emacs will also update the system-defined font dynamically. 如果你更改了系统范围的等宽字体,Emacs 也会动态更新系统定义的字体。

(setopt font-use-system-font t)

You can resize your frames or windows to any size instead of being limited to whole-character steps. 你可以将框架或窗口调整为任意大小,而不受限于字符单位的步长。

(setopt frame-resize-pixelwise t) (setopt window-resize-pixelwise t)

The frame size will stay the same even if you change the font, menu bar, tool bar, tab bar, internal borders, fringes, or scroll bars. 即使你更改了字体、菜单栏、工具栏、标签栏、内部边框、边缘(fringes)或滚动条,框架大小也会保持不变。

(setopt frame-inhibit-implied-resize t)

If a mode line is wider than the currently selected window, it is compressed by replacing repeating spaces with a single space. 如果模式行比当前选定的窗口宽,它会通过将重复的空格替换为单个空格来进行压缩。

(setopt mode-line-compact ‘long)

Saving data between sessions

会话间数据保存

Minibuffer history is saved between Emacs sessions so you can use M-x and then use M-p and M-n to navigate your history. 小缓冲区(Minibuffer)历史记录会在 Emacs 会话间保存,因此你可以使用 M-x,然后使用 M-pM-n 来浏览历史记录。

(setopt savehist-mode t)

Your place in a file is saved between Emacs sessions. 你在文件中的位置会在 Emacs 会话间保存。

(setopt save-place-mode t)

Completion

补全

This set of options affects the completion candidates (the suggestions that appear when you press M-x and then TAB, or when you use TAB at other prompts). You can use the arrow keys to select completion candidates in the minibuffer, and you can use RET to select the highlighted one. 这组选项会影响补全候选词(当你按下 M-x 后按 TAB,或在其他提示符下使用 TAB 时出现的建议)。你可以使用方向键在小缓冲区中选择补全候选词,并使用 RET 键选择高亮显示的项。

(setopt minibuffer-visible-completions t)

Additional details for completion suggestions are shown before or after the suggestions. For example, M-x describe-symbol (C-h o) shows additional information. 补全建议的详细信息会显示在建议的前面或后面。例如,M-x describe-symbol (C-h o) 会显示额外信息。

(setopt completions-detailed t)