refactor: Reorganize config with use-package and optimize startup hooks
- Split monolithic init-package.el into focused modules - Convert eager `:init` blocks to lazy `:hook` - Consolidate UI settings and defer theme loading. - Remove duplicated config between GUI and terminal paths.
This commit is contained in:
@@ -4,7 +4,22 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; mac自动全屏
|
||||
;; 编码设置
|
||||
(set-selection-coding-system 'utf-8)
|
||||
(when (fboundp 'set-charset-priority)
|
||||
(set-charset-priority 'unicode))
|
||||
(set-default-coding-systems 'utf-8)
|
||||
(set-buffer-file-coding-system 'utf-8)
|
||||
(set-clipboard-coding-system 'utf-8)
|
||||
(set-file-name-coding-system 'utf-8)
|
||||
(set-keyboard-coding-system 'utf-8)
|
||||
(set-next-selection-coding-system 'utf-8)
|
||||
(set-selection-coding-system 'utf-8)
|
||||
(set-terminal-coding-system 'utf-8)
|
||||
(setq locale-coding-system 'utf-8)
|
||||
(setq system-time-locale "C")
|
||||
|
||||
;; 全屏
|
||||
(cond
|
||||
(*is-mac*
|
||||
(set-frame-parameter nil 'fullscreen 'fullscreen)
|
||||
@@ -15,7 +30,7 @@
|
||||
(toggle-frame-maximized))
|
||||
(t nil))
|
||||
|
||||
;; 配置备份文件和自动保存文件目录
|
||||
;; 备份文件和自动保存文件
|
||||
(setq backup-directory-alist
|
||||
`((".*" . ,(expand-file-name "backup/" user-emacs-directory)))
|
||||
backup-by-copying t
|
||||
@@ -23,23 +38,19 @@
|
||||
kept-new-versions 6
|
||||
kept-old-versions 2
|
||||
version-control t)
|
||||
|
||||
(setq auto-save-file-name-transforms
|
||||
`((".*" ,(expand-file-name "auto-save-list/" user-emacs-directory) t)))
|
||||
|
||||
;; 开启水平滚动
|
||||
(put 'scroll-left 'disabled nil)
|
||||
|
||||
;; 行号
|
||||
(global-display-line-numbers-mode t)
|
||||
|
||||
;; 关闭lock文件
|
||||
(setq create-lockfiles nil)
|
||||
|
||||
;; 关闭提示音
|
||||
(setq ring-bell-function 'ignore)
|
||||
|
||||
;; 同步包管理器目录
|
||||
;; 添加包管理器目录
|
||||
(cond
|
||||
(*is-windows*
|
||||
(add-to-list 'exec-path (expand-file-name "H/appppppppppp/scoop/apps/"))
|
||||
@@ -51,21 +62,7 @@
|
||||
(add-to-list 'exec-path (expand-file-name "~/.guix-home/profile/bin/"))
|
||||
(setenv "PATH" (concat (expand-file-name "~/.guix-home/profile/bin/") ":" (getenv "PATH")))))
|
||||
|
||||
;; 当文件被外部修改时自动刷新
|
||||
(global-auto-revert-mode 1)
|
||||
|
||||
;; 开启recent file mode
|
||||
(when (or (display-graphic-p) *is-android*)
|
||||
(recentf-mode)
|
||||
(setq recentf-max-saved-items 30))
|
||||
|
||||
;; 启用select delete
|
||||
(delete-selection-mode)
|
||||
|
||||
;; 启用winner mode
|
||||
(winner-mode)
|
||||
|
||||
;; 自定义scratch
|
||||
;; scratch buffer
|
||||
(setq initial-scratch-message
|
||||
"")
|
||||
|
||||
@@ -75,19 +72,9 @@
|
||||
|
||||
(advice-add 'scratch-buffer :after #'my/scratch-set-mode)
|
||||
|
||||
;; 开启server mode
|
||||
(require 'server)
|
||||
(unless (server-running-p)
|
||||
(server-start))
|
||||
|
||||
;; 窗口名
|
||||
(setq-default frame-title-format '("%b - Emacs"))
|
||||
|
||||
;; electirc-pair-mode
|
||||
(add-hook 'org-mode-hook 'electric-pair-local-mode)
|
||||
(with-eval-after-load 'elec-pair
|
||||
(setq electric-pair-pairs (append '((?\~ . ?\~) (?\= . ?\=)) electric-pair-pairs)))
|
||||
|
||||
;; 关闭native compile警告
|
||||
(setq native-comp-async-warnings-errors-kind 'silent)
|
||||
|
||||
@@ -99,25 +86,6 @@
|
||||
;; 移动到垃圾桶
|
||||
(setq delete-by-moving-to-trash t)
|
||||
|
||||
;; 让xref用rg
|
||||
(setq xref-search-program
|
||||
(cond
|
||||
((or (executable-find "ripgrep")
|
||||
(executable-find "rg"))
|
||||
'ripgrep)
|
||||
(t 'grep)))
|
||||
|
||||
(setq switch-to-buffer-obey-display-actions t)
|
||||
|
||||
;; 优化换行规则
|
||||
(setq word-wrap-by-category t)
|
||||
|
||||
;; kill-line删除换行符
|
||||
(setq kill-whole-line t)
|
||||
|
||||
;; 更方便地pop mark
|
||||
(setq set-mark-command-repeat-pop t)
|
||||
|
||||
(provide 'init-startup)
|
||||
|
||||
;;; init-startup.el ends here
|
||||
|
||||
Reference in New Issue
Block a user