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安装,确保获取到最新版本:
- 按下
M-x(Alt+x) - 输入
package-install并回车 - 输入
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
相关产品推荐
相关产品推荐

