You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Emacs 27.1安装Modus Themes报错:modus-themes-load-themes函数未定义

解决Emacs 27.1安装Modus Themes的报错问题

报错原因

你遇到的Symbol’s function definition is void: modus-themes-load-themes错误,是因为modus-themes-load-themes是较新版本Modus Themes才引入的函数,而Emacs 27.1自带的Modus Themes版本偏旧,或者你安装的版本未包含这个函数,导致调用时找不到定义。

解决方案

步骤1:确保安装最新版Modus Themes

先手动执行MELPA安装,确保获取到最新版本:

  1. 按下M-x(Alt+x)
  2. 输入package-install并回车
  3. 输入modus-themes并回车,等待安装完成

步骤2:修正配置文件

移除不存在的modus-themes-load-themes调用,修改后的配置如下:

(use-package modus-themes
  :ensure t ; 强制从MELPA安装最新版,覆盖Emacs自带的旧版本
  :init
  ;; 保留你的自定义配置
  (setq modus-themes-italic-constructs t
        modus-themes-bold-constructs nil
        modus-themes-region '(bg-only no-extend))
  :config
  ;; 直接加载主题(新版本支持这个函数)
  (modus-themes-load-operandi) ; 切换成 (modus-themes-load-vivendi) 即可加载深色主题
  :bind ("<f5>" . modus-themes-toggle))

兼容旧版本的备选配置

如果安装后仍然提示modus-themes-load-operandi或modus-themes-toggle不存在,说明版本还是偏旧,改用原生load-theme函数实现:

(use-package modus-themes
  :ensure t
  :init
  (setq modus-themes-italic-constructs t
        modus-themes-bold-constructs nil
        modus-themes-region '(bg-only no-extend))
  :config
  ;; 加载浅色主题,t参数表示强制加载不询问
  (load-theme 'modus-operandi t)
  :bind ("<f5>" . (lambda ()
                    (interactive)
                    ;; 手动实现主题切换逻辑
                    (if (eq (car custom-enabled-themes) 'modus-operandi)
                        (load-theme 'modus-vivendi t)
                      (load-theme 'modus-operandi t)))))

验证方法

修改配置后,按下M-x输入eval-buffer回车,重新加载配置文件,确认报错消失,主题正常加载。

内容的提问来源于stack exchange,提问作者Gub

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 08:07:43