commit 8c1c211e4b8884fad5b19ff7804085920a32884b Author: trogloxene Date: Sun Mar 15 12:56:10 2026 +0800 first commit diff --git a/custom.el b/custom.el new file mode 100644 index 0000000..8219b7c --- /dev/null +++ b/custom.el @@ -0,0 +1,22 @@ +;;; -*- lexical-binding: t -*- +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(custom-safe-themes + '("c98e359e2ec6d95e29f006202641f7bafc9e6e204f937d4d518c3ef154ed479b" + "7fea145741b3ca719ae45e6533ad1f49b2a43bf199d9afaee5b6135fd9e6f9b8" + "2b0fcc7cc9be4c09ec5c75405260a85e41691abb1ee28d29fcd5521e4fca575b" + default)) + '(package-selected-packages + '(ace-window benchmark-init cape cnfonts corfu crux drag-stuff eglot + embark-consult everything exec-path-form-shell gcmh + hungry-delete marginalia multiple-cursors orderless + restart-emacs smart-mode-line solarized-theme vertico))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) diff --git a/early-init.el b/early-init.el new file mode 100644 index 0000000..971650d --- /dev/null +++ b/early-init.el @@ -0,0 +1,13 @@ +(setq package-enable-at-startup nil) + +(setq inhibit-startup-screen t) ;; 禁用开始菜单 +(tool-bar-mode -1) ;; 禁用工具栏 +(menu-bar-mode -1) ;; 禁用菜单栏 +(scroll-bar-mode -1) ;; 禁用滚动条 +(setq display-line-numbers-type 'relative) +(global-display-line-numbers-mode t) ;; 启用行号 + +;; 启动时初始窗口最大化 +(add-to-list 'initial-frame-alist '(fullscreen . maximized)) +;; 之后新建的窗口也默认最大化 +(add-to-list 'default-frame-alist '(fullscreen . maximized)) diff --git a/init.el b/init.el new file mode 100644 index 0000000..c8acafa --- /dev/null +++ b/init.el @@ -0,0 +1,20 @@ +;;; init.el +;;; -*- lexical-binding: t -*- + +(add-to-list 'load-path + (expand-file-name (concat user-emacs-directory "lisp"))) + +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) + +(when (file-exists-p custom-file) + (load-file custom-file)) + +(require 'init-const) +(require 'init-startup) +(require 'init-elpa) +(require 'init-package) +(require 'init-org) +(require 'init-completion) +(require 'init-kbd) +(require 'init-ui) +(require 'init-segmentation) diff --git a/lisp/init-completion.el b/lisp/init-completion.el new file mode 100644 index 0000000..8a141ba --- /dev/null +++ b/lisp/init-completion.el @@ -0,0 +1,50 @@ +;;; init-completion.el +;;; -*- lexical-binding: t -*- + +;; eglot +(use-package eglot + :hook ((python-mode . eglot-ensure)) + + :config + (setq eglot-send-changes-idle-time 0.5)) + +;; corfu +(use-package corfu + :custom + (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode) + (corfu-echo-mode) + + :custom + (corfu-popupinfo-delay 0.5) + (corfu-auto t) + + :bind + (:map corfu-map + ("RET" . nil))) + +(use-package emacs + :custom + (tab-always-indent 'complete) + + ;; Emacs 30 and newer: Disable Ispell completion function. + ;; Try `cape-dict' as an alternative. + (text-mode-ispell-word-completion nil) + + ;; Hide commands in M-x which do not apply to the current mode. Corfu + ;; commands are hidden, since they are not used via M-x. This setting is + ;; useful beyond Corfu. + (read-extended-command-predicate #'command-completion-default-include-p)) + +;; cape +(use-package cape + :init + (add-to-list 'completion-at-point-functions #'cape-file) ;; 文件补全 + (setq-local completion-at-point-functions + (list (cape-capf-super #'cape-dabbrev)))) ;; 启用dabbrev + +(provide 'init-completion) diff --git a/lisp/init-const.el b/lisp/init-const.el new file mode 100644 index 0000000..de2a5d5 --- /dev/null +++ b/lisp/init-const.el @@ -0,0 +1,35 @@ +;;; init-const.el +;;; -*- lexical-binding: t -*- + +;; 识别操作系统 +(defconst *is-mac* (eq system-type 'darwin)) +(defconst *is-linux* (eq system-type 'gnu/linux)) +(defconst *is-windows* (or (eq system-type 'ms-dos) + (eq system-type 'windows-nt))) + +;; Windows 系统编码设置 +(when *is-windows* + ;; 设置默认编码环境 + (set-language-environment "UTF-8") + (prefer-coding-system 'utf-8) + (set-default-coding-systems 'utf-8) + (set-terminal-coding-system 'utf-8) + (set-keyboard-coding-system 'utf-8) + (setq default-buffer-file-coding-system 'utf-8) + + ;; 设置进程通信编码 + (setq default-process-coding-system '(utf-8 . utf-8)) + + ;; 为特定程序设置编码 + (add-to-list 'process-coding-system-alist '("rg" utf-8 . utf-8)) + (add-to-list 'process-coding-system-alist '("ripgrep" utf-8 . utf-8)) + (add-to-list 'process-coding-system-alist '("grep" utf-8 . utf-8)) + (add-to-list 'process-coding-system-alist '("find" utf-8 . utf-8)) + (add-to-list 'process-coding-system-alist '("fd" utf-8 . utf-8)) + (add-to-list 'process-coding-system-alist '("fdfind" utf-8 . utf-8)) + + ;; Windows 文件名 Unicode 支持 + (setq w32-unicode-filenames t) + (setq w32-system-coding-system 'utf-8)) + +(provide 'init-const) diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el new file mode 100644 index 0000000..74c4614 --- /dev/null +++ b/lisp/init-elpa.el @@ -0,0 +1,49 @@ +;;; init-elpa.el +;;; -*- lexical-binding: t -*- + +;; Clash 代理配置 +(setq url-proxy-services + '(("http" . "127.0.0.1:7890") + ("https" . "127.0.0.1:7890") + ("no_proxy" . "\\(localhost\\|127\\.0\\.0\\.1\\|192\\.168\\.*\\)"))) + +;; straight.el +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name + "straight/repos/straight.el/bootstrap.el" + (or (bound-and-true-p straight-base-dir) + user-emacs-directory))) + (bootstrap-version 7)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) + +;; 安装el-patch +(use-package el-patch + :straight t) + +;; 从develop分支而不是main分支获取straight.el +(setq straight-repository-branch t) + +;; 安装use-package +(straight-use-package 'use-package) + +;; 配置 use-package +(setq use-package-always-defer t + use-package-expand-minimally t + use-package-verbose t + straight-use-package-version t + straight-use-package-by-default t) + +;; 安装benchmark-init +(use-package benchmark-init + :init (benchmark-init/activate) + :hook (after-init . benchmark-init/deactivate)) + +(provide 'init-elpa) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el new file mode 100644 index 0000000..b7e34d0 --- /dev/null +++ b/lisp/init-kbd.el @@ -0,0 +1,169 @@ +;;; init-kbd.el +;;; -*- lexical-binding: t -*- + +;; 修改mac键位 +(when *is-mac* + (setq mac-command-modifier 'meta) + (setq mac-option-modifier 'none)) + +;; 使用F2打开init.el +(defun open-init-file() + "Open user's init.el file in ~/.emacs.d +这是一段文档" + (interactive) + (find-file "~/.emacs.d/init.el")) + +(global-set-key (kbd "") 'open-init-file) + +;; 快速打开函数与变量的定义 +(global-set-key (kbd "C-h C-f") 'find-function) +(global-set-key (kbd "C-h C-v") 'find-variable) + +;; 根据平台使用不同的重启方式 +(if *is-windows* + (progn + (defun restart-emacs () + "Restart emacs (for Windows)" + (interactive) + (save-some-buffers) + (w32-shell-execute "open" "runemacs.exe") + (kill-emacs)) + (global-set-key (kbd "C-c r") 'restart-emacs)) + (global-set-key (kbd "C-c r") 'restart-emacs)) + +;; multiple cursors +(global-set-key (kbd "C-c c c") 'mc/edit-lines) +(global-set-key (kbd "C-c c a") 'mc/mark-all-in-region) +(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) +(global-set-key (kbd "C->") 'mc/mark-next-like-this) + +;; 快速复制当前行 +(defun duplicate-and-move-to-next-line() + (interactive) + (progn + (duplicate-line) + (next-line))) +(global-set-key (kbd "C-,") 'duplicate-and-move-to-next-line) + +;; 切换buffer +(defun my-tab-line-buffers () + "Get list of buffers shown in tab-line." + (mapcar (lambda (tab) + (if (consp tab) (cdr tab) tab)) + (funcall tab-line-tabs-function))) + +(defun previous-buffer-with-tab-line () + "Switch to previous buffer in tab-line order" + (interactive) + (let ((already-enabled global-tab-line-mode)) + (unless already-enabled + (global-tab-line-mode 1)) + (let* ((buffers (my-tab-line-buffers)) + (current (current-buffer)) + (pos (cl-position current buffers))) + (when pos + (switch-to-buffer + (nth (mod (1- pos) (length buffers)) buffers)))) + (unless already-enabled + (run-with-idle-timer 0.5 nil (lambda () (global-tab-line-mode -1)))))) + +(defun next-buffer-with-tab-line () + "Switch to next buffer in tab-line order" + (interactive) + (let ((already-enabled global-tab-line-mode)) + (unless already-enabled + (global-tab-line-mode 1)) + (let* ((buffers (my-tab-line-buffers)) + (current (current-buffer)) + (pos (cl-position current buffers))) + (when pos + (switch-to-buffer + (nth (mod (1+ pos) (length buffers)) buffers)))) + (unless already-enabled + (run-with-idle-timer 0.5 nil (lambda () (global-tab-line-mode -1)))))) + +(global-set-key (kbd "") 'previous-buffer-with-tab-line) +(global-set-key (kbd "") 'previous-buffer) +(global-set-key (kbd "M-[") 'previous-buffer) +(global-set-key (kbd "") 'next-buffer-with-tab-line) +(global-set-key (kbd "") 'next-buffer) +(global-set-key (kbd "M-]") 'next-buffer) + +;; 段落导航 +(global-set-key (kbd "M-p") 'backward-paragraph) +(global-set-key (kbd "M-n") 'forward-paragraph) + +;; 打开tab-line-mode +(global-set-key (kbd "C-c u t") 'global-tab-line-mode) +(global-set-key (kbd "") 'global-tab-line-mode) + +;; 中键使用embark打开定义 +(global-set-key (kbd "") 'xref-find-definitions) + +;; 使用C-c s切换到scrath buffer +(global-set-key (kbd "C-c ") 'scratch-buffer) + +;; 使用M-<方向键>调整window +(global-set-key (kbd "M-") 'shrink-window-horizontally) +(global-set-key (kbd "M-") 'enlarge-window-horizontally) +(global-set-key (kbd "M-") 'enlarge-window) +(global-set-key (kbd "M-") 'shrink-window) + +;; crux相关 +(global-set-key (kbd "C-") 'crux-kill-line-backwards) ;; C-DEL kill line backwards +(global-set-key (kbd "C-c k") 'comment-line) ;; 快速注释 +(global-set-key (kbd "C-k") 'crux-smart-kill-line) ;; smart kill line +(global-set-key (kbd "C-a") 'crux-move-beginning-of-line) ;; 移动到第一个缩进而非行首 +(global-set-key (kbd "C-x K") 'crux-kill-other-buffers) ;; 删除除当前buffer之外的buffer + +;; consult +(global-set-key (kbd "C-x b") 'consult-buffer) ;; buffer菜单 +(global-set-key (kbd "C-s") 'consult-line) ;; 搜索 +(global-set-key (kbd "C-c i") 'consult-imenu) ;; imenu +(global-set-key (kbd "C-c f r") 'consult-recent-file) ;; 最近打开 +(global-set-key (kbd "C-c f f") 'consult-fd) ;; 调用fd进行目录内搜索 +(global-set-key (kbd "C-c f l") 'consult-locate) ;; consult-locate +(global-set-key (kbd "C-c f g") 'consult-ripgrep) ;; consult-ripgrep +(global-set-key (kbd "C-c y") 'consult-yank-from-kill-ring) ;; 从kill ring中粘贴 + +;; hungry-delete +(global-set-key (kbd "C-c DEL") 'hungry-delete-backward) ;; 向后删除到第一个非空字符 +(global-set-key (kbd "C-c d") 'hungry-delete-forward) ;; 向前删除到第一个非空字符 + +;; drag-stuff +(global-set-key (kbd "M-P") 'drag-stuff-up) +(global-set-key (kbd "M-N") 'drag-stuff-down) + +;; ace-windows +(global-set-key (kbd "M-o") 'ace-window) + +;; embark,修饰键之后加C-h可以查看所有指令 +(global-set-key (kbd "C-;") 'embark-act) + +;; 打开目录 +(defun consult-directory-externally (file) + "Open FILE externally using the default application of the system." + (interactive "fOpen externally: ") + (if (and (eq system-type 'windows-nt) + (fboundp 'w32-shell-execute)) + (shell-command-to-string (encode-coding-string (replace-regexp-in-string "/" "\\\\" + (format "explorer.exe %s" (file-name-directory (expand-file-name file)))) + 'gbk)) + (call-process (pcase system-type + ('darwin "open") + ('cygwin "cygstart") + (_ "xdg-open")) + nil 0 nil + (file-name-directory (expand-file-name file))))) + +(with-eval-after-load 'embark + (define-key embark-file-map (kbd "d") 'consult-directory-externally)) + +;;打开当前文件的目录 +(defun my-open-current-directory () + (interactive) + (consult-directory-externally default-directory)) + +(global-set-key (kbd "C-c f d") 'my-open-current-directory) + +(provide 'init-kbd) diff --git a/lisp/init-org.el b/lisp/init-org.el new file mode 100644 index 0000000..d75fc9e --- /dev/null +++ b/lisp/init-org.el @@ -0,0 +1,50 @@ +;;; init-org.el +;;; -*- lexical-binding: t -*- + +(use-package org) + +;; (if *is-windows* +;; (progn (run-with-idle-timer +;; 0.5 nil +;; (lambda () +;; (with-temp-buffer +;; (org-mode) +;; (org-mode)) +;; (message "Org preloaded"))))) + +(setq org-todo-keywords + (quote ((sequence "TODO(t)" "STARTED(s)" "|" "DONE(d!/!)") + (sequence "WAITING(w@/!)" "SOMEDAY(S)" "|" "CANCELLED(c@/!)" "MEETING(m)" "PHONE(p)")))) + +(setq system-time-locale "C") + +;; org-contrib 和 org-checklist +(use-package org-contrib + :straight (org-contrib :type git :host github :repo "emacsmirror/org-contrib" + :depth 1)) + +(add-hook 'org-mode-hook + (lambda () + (require 'org-checklist nil t))) + +(setq org-log-done t) +(setq org-log-into-drawer t) + +(global-set-key (kbd "C-c a") 'org-agenda) +(setq org-agenda-files '("d:/emacs/org/learning-org-mode.org")) +(setq org-agenda-span 'day) + +(setq org-capture-templates + '(("t" "Todo" entry (file+headline "d:/emacs/org/learning-org-mode.org" "Workspace") + "* TODO [#B] %?\n %i\n %U" + :empty-lines 1))) + +(global-set-key (kbd "C-c o c") 'org-capture) + +(setq org-agenda-custom-commands + '(("c" "important stuff" + ((tags-todo "+PRIORITY=\"A\""))) + ;; ...other commands here + )) + +(provide 'init-org) diff --git a/lisp/init-package.el b/lisp/init-package.el new file mode 100644 index 0000000..234dc08 --- /dev/null +++ b/lisp/init-package.el @@ -0,0 +1,91 @@ +;;; init-package.el +;;; -*- lexical-binding: t -*- + +;; 安装gcmh用于管理内存回收 +(use-package gcmh + :init + (setq gcmh-idle-delay 5 ; 空闲 5 秒后 GC + gcmh-high-cons-threshold (* 16 1024 1024)) ; 高阈值 16MB + :config + (gcmh-mode 1)) + +(use-package restart-emacs) + +;; 安装multiple-cursors +(use-package multiple-cursors) + +;; 安装crux,增强快捷键,快捷键配置在init-kbd.el中 +(use-package crux) + +;; 安装hungry-delete +(use-package hungry-delete) + +;; 安装drag-stuff,拖动字符 +(use-package drag-stuff) + +;; 安装which-key,快捷键提示 +(use-package which-key + :defer 0 + :config + (which-key-mode)) + +;; 安装ace-windows,快速切换窗口 +(use-package ace-window) + +;; 安装vertico +(use-package vertico + :init (vertico-mode t)) + +;; 安装orderless,用于模糊搜索 +(use-package orderless + :custom (completion-styles '(orderless basic))) + +;; 安装marginalia,用于命令注释 +(use-package marginalia + :init (marginalia-mode)) + +;; 安装consult,增强搜索和其他菜单 +(use-package consult) + +;; 安装embark,一个菜单,用用就明白了 +(use-package embark + :config (setq prefix-help-command 'embark-prefix-help-command)) + +;; 安装embark-consult和wgrep +(use-package embark-consult) +(use-package wgrep) + +(with-eval-after-load + 'consult + '(with-eval-after-load + 'embark + '(progn + (require 'embark-consult) + (add-hook + 'embark-collect-mode-hook + #'consult-preview-at-point-mode)))) + +(define-key minibuffer-local-map (kbd "C-c C-e") 'embark-export) + +(progn + (setq consult-locate-args (encode-coding-string "es.exe -i -p -r" 'gbk)) + (add-to-list 'process-coding-system-alist '("es" gbk . gbk))) + +;; 启用savehist,保存命令顺序 +(use-package savehist + :hook (after-init . savehist-mode) + :init (setq enable-recursive-minibuffers t + history-length 1000 + savehist-additional-variables '(mark-ring + global-mark-ring + search-ring + regexp-search-ring + extended-command-history) + savehist-autosave-interval 300) + ) + +;; saveplace,保存光标位置 +(use-package saveplace + :hook (after-init . save-place-mode)) + +(provide 'init-package) diff --git a/lisp/init-segmentation.el b/lisp/init-segmentation.el new file mode 100644 index 0000000..9699057 --- /dev/null +++ b/lisp/init-segmentation.el @@ -0,0 +1,32 @@ +;;; init-segmentation.el +;;; -*- lexical-binding: t -*- + +;; emacs-chinese-word-segmentation 配置 +(when *is-windows* + (add-to-list 'load-path "D:/emacs/emacs-chinese-word-segmentation") + ;; 设置为进程调用方式 + (setq cns-process-type 'shell) + ;; 设置可执行文件路径 + (setq cns-prog "D:/emacs/emacs-chinese-word-segmentation/cnws.exe") + ;; 设置字典目录 + (setq cns-dict-directory "D:/emacs/emacs-chinese-word-segmentation/cppjieba/dict") + ;; 直接设置进程命令,绕过 Windows shell 检测 + (setq cns-process-shell-command + (format "%s %s %s %s %s %s" + cns-prog + (concat (file-name-as-directory cns-dict-directory) "jieba.dict.utf8") + (concat (file-name-as-directory cns-dict-directory) "hmm_model.utf8") + (concat (file-name-as-directory cns-dict-directory) "user.dict.utf8") + (concat (file-name-as-directory cns-dict-directory) "idf.utf8") + (concat (file-name-as-directory cns-dict-directory) "stop_words.utf8"))) + ;; 其他配置 + (setq cns-recent-segmentation-limit 40) + (require 'cns nil t) + ;; 自动启动 + (when (featurep 'cns) + (add-hook 'find-file-hook 'cns-auto-enable)) + ;; 取消C-绑定 + (with-eval-after-load 'cns + (define-key cns-mode-map (kbd "C-") nil))) + +(provide 'init-segmentation) diff --git a/lisp/init-startup.el b/lisp/init-startup.el new file mode 100644 index 0000000..47e8dbf --- /dev/null +++ b/lisp/init-startup.el @@ -0,0 +1,49 @@ +;;; init-startup.el +;;; -*- lexical-binding: t -*- + +;; 配置备份文件和自动保存文件目录 +(setq backup-directory-alist + `((".*" . ,(expand-file-name "backup/" user-emacs-directory))) + backup-by-copying t + delete-old-versions t + 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))) + +;; 关闭lock文件 +(setq create-lockfiles nil) + +;; 关闭提示音 +(setq ring-bell-function 'ignore) + +;; 同步scoop目录 +(when *is-windows* + ;; 将 Scoop 的 Python Scripts 添加到 exec-path + (add-to-list 'exec-path (expand-file-name "H/appppppppppp/scoop/apps/")) + ;; 同时更新环境变量 PATH(供子进程使用) + (setenv "PATH" (concat (expand-file-name "H/appppppppppp/scoop/apps/") ";" (getenv "PATH")))) + +;; 当文件被外部修改时自动刷新 +(global-auto-revert-mode 1) + +;; 开启rencent file mode +(recentf-mode) +(setq recentf-max-saved-items 20) ;; 最大保存数量 + +;; 启用select delete +(delete-selection-mode) + +;; 启用winner mode +(winner-mode) + +;; 自定义scratch +(setq initial-scratch-message + ";; SCRATCH SCRATCH SCRATCH\n\n") + +;; 开启server mode +(server-start) + +(provide 'init-startup) diff --git a/lisp/init-ui.el b/lisp/init-ui.el new file mode 100644 index 0000000..d968ed1 --- /dev/null +++ b/lisp/init-ui.el @@ -0,0 +1,96 @@ +;;; init-ui.el +;;; -*- lexical-binding: t -*- + +;; 设置系统编码 +(when (fboundp 'set-charset-priority) + (set-charset-priority 'unicode)) + +(set-language-environment 'chinese-gbk) +(prefer-coding-system 'utf-8-auto) + +;; 安装solarized dark +(use-package solarized-theme) +(load-theme 'solarized-dark t) + +;; 安装smart-mode-line +(use-package smart-mode-line + :defer 0.5 + :config + (setq sml/no-confirm-load-theme t + sml/theme 'respectful) + (sml/setup)) + +;; 高亮当前行 +(global-hl-line-mode t) + +;; 显示文件大小 +(size-indication-mode t) + +;; 显示行号列号 +(column-number-mode t) + +;; 配置字体 +(defvar cn-fonts-list '("Sarasa Fixed TC" "STHeiti" "微软雅黑" "文泉译微米黑") + "定义使用的中文字体候选列表") + +(defvar en-fonts-list '("Sarasa Fixed TC" "Courier New" "Monaco" "Ubuntu Mono") + "定义使用的英文字体候选列表") + +(defvar emoji-fonts-list '("Apple Color Emoji" "Segoe UI Emoji" "Noto Color Emoji" "Symbola" "Symbol") + "定义使用Emoji字体候选列表") + +(defun tenon--available-font (font-list) + "从 FONT-LIST 中寻找第一个系统中可用的字" + (catch 'found + (dolist (font font-list) + (when (member font (font-family-list)) + (throw 'found font))))) + +;; 设置字体大小和字重变量 +(defvar tenon-font-size 125 + "默认字体大小") +(defvar tenon-font-weight 'light + "默认字重,选项有ultra-light,light,normal,medium,semibold,bold") + +;; 定义函数 +;;;###autoload +(defun tenon--font-setup () + "Font setup." + (interactive) + (let* ((cf (tenon--available-font cn-fonts-list)) + (ef (tenon--available-font en-fonts-list)) + (em (tenon--available-font emoji-fonts-list))) + (when ef + (dolist (face '(default fixed-pitch fixed-pitch-serif variable-pitch)) + (set-face-attribute face nil + :family ef + :height tenon-font-size + :weight tenon-font-weight))) + (when em + (dolist (charset `(unicode unicode-bmp ,(if (> emacs-major-version 27) 'emoji 'symbol))) + (set-fontset-font t charset em nil 'prepend))) + (when cf + (dolist (charset '(kana han cjk-misc bopomofo)) + (set-fontset-font t charset cf)) + (setq face-font-rescale-alist + (mapcar (lambda (item) (cons item 1)) `(,cf ,em)))))) + +;; 延迟执行字体设置 +(add-hook 'after-init-hook #'tenon--font-setup) + +;; 添加个人字体到 cnfonts +(setq cnfonts-personal-fontnames + '(("Sarasa Fixed TC") ; 英文字体 + ("Sarasa Fixed TC") ; 中文字体 + nil ; Ext-B 字体(可选) + nil ; Symbol 字体(可选) + nil)) ; 装饰字体(可选) + +;; 安装cnfonts脚本,用于修复中英文对齐 +(use-package cnfonts + :defer 0 + :config + (cnfonts-mode 1) + (cnfonts--select-profile "profile1")) + +(provide 'init-ui)