Emacs 配置

编译

Ubuntu 依赖

1
2
sudo apt update
sudo apt build-dep -y emacs

macOS 依赖

1
brew install mailutils libxml2

编译步骤

1
2
3
4
5
# git clone https://git.savannah.gnu.org/git/emacs.git

./autogen.sh
./configure --prefix $HOME/.x
make && make install

主题

当 Emacs 运行在 Tmux 中时,如果颜色显示不正确,需要在 .tmux.conf 中配置终端颜色和模式,关键是设置 default-terminal 以支持 256 色,推荐使用 tmux-256color 以获得最佳兼容性。

1
2
set -g default-terminal "tmux-256color"
set -as terminal-overrides ",xterm-256color:Tc"

然后在 Emacs 中启用 True Color 支持(按需):

1
2
3
4
5
6
7
;; Enable True Color support in Emacs when running inside Tmux
(when (getenv "TMUX")
  (unless (display-graphic-p)
    (add-to-list 'default-frame-alist '(background-mode . dark))
    (set-terminal-parameter nil 'background-mode 'dark)
    (setq term-term-name "xterm-256color")
    (setenv "COLORTERM" "truecolor")))

配置说明:

  • set -g default-terminal "tmux-256color" :此选项告诉 tmux 默认的终端模式。使用 tmux-256color 比 screen-256color 更能正确处理表情符号和真彩色。
  • set -ag terminal-overrides ...:Tc :这个设置强制 tmux 内部使用真彩色 (24-bit color),这对于 Neovim 或现代终端主题至关重要。

配置完成后,请执行 tmux source-file ~/.tmux.conf 重新加载配置。