Emacs 从零开始写配置: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 14: | Line 14: | ||
== load-path == | == load-path == | ||
好的 load-path 方式为,自动扫描插件目录,在插件出问题时可以全删干净,不影响早期有效配置。 | 好的 load-path 方式为,自动扫描插件目录,在插件出问题时可以全删干净,不影响早期有效配置。 | ||
<syntaxhighlight lang="elisp" line> | |||
;; 1 设置插件目录 | |||
(add-to-list 'load-path (expand-file-name "lisp/" user-emacs-directory)) | |||
;; 2 遍历插件子目录 | |||
(dolist (dir (directory-files (expand-file-name "lisp/" user-emacs-directory) t "^[^.]" t)) | |||
(when (file-directory-p dir) | |||
(add-to-list 'load-path dir))) | |||
;; 3 按功能加载配置 | |||
(require 'ui) | |||
(require 'editing) | |||
(require 'completion) | |||
(require 'keybindings) | |||
;; 4 加载主题(可选) | |||
(add-to-list 'custom-theme-load-path (expand-file-name "themes/doom-one" user-emacs-directory)) | |||
(load-theme 'doom-one t) | |||
</syntaxhighlight> | |||
Revision as of 15:36, 17 March 2026
据 ChatGPT 所说,Emacs 启动顺序为:
1 启动 C 核心 2 初始化 load-path 3 加载 site-start.el(系统级配置) 4 加载 early-init.el(用户早期配置) 5 初始化 package.el 6 加载 init.el 或 .emacs(用户配置) 7 Emacs 完全启动
平台
load-path
好的 load-path 方式为,自动扫描插件目录,在插件出问题时可以全删干净,不影响早期有效配置。
;; 1 设置插件目录
(add-to-list 'load-path (expand-file-name "lisp/" user-emacs-directory))
;; 2 遍历插件子目录
(dolist (dir (directory-files (expand-file-name "lisp/" user-emacs-directory) t "^[^.]" t))
(when (file-directory-p dir)
(add-to-list 'load-path dir)))
;; 3 按功能加载配置
(require 'ui)
(require 'editing)
(require 'completion)
(require 'keybindings)
;; 4 加载主题(可选)
(add-to-list 'custom-theme-load-path (expand-file-name "themes/doom-one" user-emacs-directory))
(load-theme 'doom-one t)