Config: streamline config structure and reorganize modules

- Remove init-workspace.el and redundant UI/font/autothemer setup
- Add init-prog.el for programming language configs (treesit, lua, scheme, etc.)
- Defer org-refile loading via org-mode hook
- Adjust load order in init.el, add init-proxy
- Fix indentation and formatting issues
This commit is contained in:
User
2026-04-26 07:49:55 +08:00
parent c6cf0ef9d8
commit 4d810f270f
13 changed files with 205 additions and 347 deletions

2
.gitignore vendored
View File

@@ -7,4 +7,6 @@
!lisp/**/
!lisp/**/*.el
lisp/init-proxy.el
!.gitignore

View File

@@ -16,18 +16,18 @@
(global-display-line-numbers-mode t)
(require 'init-const)
(load "init-proxy" t)
(require 'init-startup)
(require 'init-elpa)
(require 'init-package)
(require 'init-emms)
(require 'init-org)
(require 'init-org-refile)
(require 'init-prog)
(require 'init-completion)
(require 'init-window)
(require 'init-exwm)
(require 'init-dired)
(require 'init-gptel)
(require 'init-workspace)
(require 'init-ui)
(require 'init-kbd-func)
(require 'init-kbd)

View File

@@ -107,31 +107,6 @@
(advice-add 'eglot-completion-at-point :around #'cape-wrap-nonexclusive)
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-nonexclusive))
;; tree-sitter
(use-package treesit-auto
:demand t
:config
(setq treesit-auto-install 'prompt)
(global-treesit-auto-mode)
(setq treesit-font-lock-level 4))
;; lua
(use-package lua-ts-mode
:mode ("\\.lua\\'" . lua-ts-mode)
:config
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-ts-mode)))
;; ahk
(use-package ahk-mode)
;; scheme
(use-package geiser
:config
(with-eval-after-load 'geiser
(setq geiser-default-implementation 'guile)))
(use-package geiser-guile)
(provide 'init-completion)
;;; init-completion.el ends here

View File

@@ -11,24 +11,12 @@
(setq dashboard-banner-logo-title (format "%s" emacs-version))
(setq dashboard-banner-ascii " ##### # # # # ####### # # # ##### ##### \n# # ## # # # # ## ## # # # # # # \n# # # # # # # # # # # # # # # \n# #### # # # # # ##### # # # # # # ##### \n# # # # # # # # # # ####### # # \n# # # ## # # # # # # # # # # # \n ##### # # ##### ####### # # # # ##### ##### ")
(setq dashboard-startup-banner 'ascii)
(setq dashboard-footer-messages '("hello"))
(setq dashboard-center-content t)
(setq dashboard-navigation-cycle t)
(setq dashboard-items '((recents . 15)
(bookmarks . 5)
(projects . 5)))
(add-hook 'emacs-startup-hook
(lambda()
(setq my-emacs-startup-time (format-time-string "%Y-%m-%d %H:%M:%S"))))
(defun my/dashboard-insert-copyright ()
"Insert copyright in the footer."
(dashboard-insert-center
(propertize (format "\n\nEmacs started at %s" my-emacs-startup-time)
'face 'font-lock-comment-face)))
(advice-add #'dashboard-insert-footer :after #'my/dashboard-insert-copyright)
(setq dashboard-footer-messages '(
"Hello."
"Hi."
))
(setq dashboard-item-shortcuts '((recents . "r") (bookmarks . "b") (projects . "p") (agenda . "a") (registers . "e"))))
(provide 'init-dashboard)

View File

@@ -4,27 +4,6 @@
;;; Code:
;; Clash 代理配置
;; (if *is-linux*
;; (progn
;; (setq url-proxy-services
;; '(("http" . "192.168.31.121:7890")
;; ("https" . "192.168.31.121:7890")
;; ("no_proxy" . "\\(localhost\\|127\\.0\\.0\\.1\\|192\\.168\\.*\\)")))
;; (setenv "http_proxy" "192.168.31.121:7890")
;; (setenv "https_proxy" "192.168.31.121:7890"))
(progn
(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\\.*\\)")))
(setenv "http_proxy" "127.0.0.1:7890")
(setenv "https_proxy" "127.0.0.1:7890"))
;; )
;; straight.el
(defvar bootstrap-version)
(let ((bootstrap-file

View File

@@ -21,40 +21,7 @@
(add-hook 'gptel-post-response-functions 'gptel-end-of-response)
(add-hook 'gptel-post-stream-hook 'gptel-auto-scroll)
(setq gptel-prompt-prefix-alist '((markdown-mode . "### ") (org-mode . "** User: ") (text-mode . "### ")))
;; 读取文件
(gptel-make-tool
:function (lambda (filepath)
(with-temp-buffer
(insert-file-contents (expand-file-name filepath))
(buffer-string)))
:name "read_file"
:description "Read and display the contents of a file"
:args '((:name "filepath" :type string :description "Path to the file"))
:category "filesystem")
;; 创建文件
(gptel-make-tool
:name "create_file" ; javascript-style snake_case name
:function (lambda (path filename content) ; the function that runs
(let ((full-path (expand-file-name filename path)))
(with-temp-buffer
(insert content)
(write-file full-path))
(format "Created file %s in %s" filename path)))
:description "Create a new file with the specified content"
:args (list '(:name "path" ; a list of argument specifications
:type string
:description "The directory where to create the file")
'(:name "filename"
:type string
:description "The name of the file to create")
'(:name "content"
:type string
:description "The content to write to the file"))
:category "filesystem") ; An arbitrary label for grouping
(setq gptel-prompt-prefix-alist '((markdown-mode . "## User: ") (org-mode . "** User: ") (text-mode . "## User: ")))
(gptel-make-tool
:name "read_buffer" ; javascript-style snake_case name

View File

@@ -6,6 +6,71 @@
(use-package org)
;; 一些随org-mode加载的基础配置
(add-hook 'org-mode-hook
(lambda ()
(require 'org-tempo)
(require 'init-org-refile)
(org-indent-mode)
(visual-line-mode)
(setq-local electric-pair-inhibit-predicate
(lambda (char)
(or (eq char ?<)
(electric-pair-default-inhibit char))))))
;; 预加载防止windows的org-mode加载卡顿
(if *is-windows*
(progn (run-with-idle-timer
0.5 nil
(lambda ()
(with-temp-buffer
(org-mode)
(org-mode))
(message "Org preloaded")))))
;; 设置标题字体大小
;; (dolist (face org-level-faces)
;; (set-face-attribute face nil :height 1))
;; log默认放入drawer中
(setq org-log-done t)
(setq org-log-into-drawer t)
;; 将系统时间(星期)设为英文,防止中文乱码
(setq system-time-locale "C")
;; 设置todo关键字
(setq org-todo-keywords
(quote ((sequence "TODO(t)" "STARTED(s)" "|" "DONE(d!/!)")
(sequence "WAITING(w@/!)" "SOMEDAY(S)" "|" "CANCELLED(c@/!)" "MEETING(m)" "PHONE(p)"))))
;; agenda相关
(cond
(*is-windows*
(setq org-agenda-files '("h:/emacs/hugo/this-is-my-blog/all-blog.org"
"h:/emacs/my-org-daily/"
"h:/emacs/my-org-note/")))
(*is-mac*
(setq org-agenda-files '("~/org/my-org-daily"
"~/org/my-org-note/")))
(*is-linux*
(setq org-agenda-files '("~/org/my-org-daily/"
"~/org/my-org-note/"))))
(setq org-agenda-span 'day)
(setq org-default-priority ?C)
(setq org-agenda-skip-function-global
'(org-agenda-skip-entry-if 'todo '("COMMENT")))
;; 批量调整表格
(defun org-table-align-all ()
"Ajust all table in current buffer."
(interactive)
(save-excursion
(goto-char (point-min))
(org-table-map-tables 'org-table-align t)))
;; org-babel scheme
(use-package ob-scheme
:straight (:type built-in)
@@ -18,11 +83,11 @@
;; org-contrib 和 org-checklist
(use-package org-contrib
:straight (org-contrib :type git :host github :repo "emacsmirror/org-contrib"
:depth 1))
:depth 1)
:config
(add-hook 'org-mode-hook
(lambda ()
(require 'org-checklist nil t)))
(require 'org-checklist nil t))))
;; org-download
(use-package org-download
@@ -36,7 +101,10 @@
(setq org-download-dragndrop t)
(setq org-image-actual-width nil)
(setq org-download-image-html-width 600)
(add-hook 'org-mode-hook 'org-display-inline-images)))
(add-hook 'org-mode-hook 'org-display-inline-images))
(with-eval-after-load 'org
(require 'org-download)
(setq org-return-follows-link t)))
;; org-journal
(use-package org-journal
@@ -111,72 +179,12 @@
(reverse entries))))
(save-buffer)))
(setq org-journal-handle-old-carryover-fn #'my/org-journal-mark-old-todos-as-comment))
(setq org-journal-handle-old-carryover-fn #'my/org-journal-mark-old-todos-as-comment)
;; 在org-journal加载cns-mode
(add-hook 'org-journal-mode-hook
(lambda ()
(global-cns-mode-enable-in-buffer)))
;; 一些随org-mode加载的基础配置
(add-hook 'org-mode-hook
(lambda ()
(require 'org-tempo)
(org-indent-mode)
(setq-local electric-pair-inhibit-predicate
(lambda (char)
(or (eq char ?<)
(electric-pair-default-inhibit char))))))
(with-eval-after-load 'org
(require 'org-download)
(setq org-return-follows-link t))
;; 预加载防止windows的org-mode加载卡顿
(if *is-windows*
(progn (run-with-idle-timer
0.5 nil
(lambda ()
(with-temp-buffer
(org-mode)
(org-mode))
(message "Org preloaded")))))
;; 设置标题字体大小
;; (dolist (face org-level-faces)
;; (set-face-attribute face nil :height 1))
;; log默认放入drawer中
(setq org-log-done t)
(setq org-log-into-drawer t)
;; 将系统时间(星期)设为英文,防止中文乱码
(setq system-time-locale "C")
;; 设置todo关键字
(setq org-todo-keywords
(quote ((sequence "TODO(t)" "STARTED(s)" "|" "DONE(d!/!)")
(sequence "WAITING(w@/!)" "SOMEDAY(S)" "|" "CANCELLED(c@/!)" "MEETING(m)" "PHONE(p)"))))
;; agenda相关
(when *is-windows*
(setq org-agenda-files '("h:/emacs/hugo/this-is-my-blog/all-blog.org"
"h:/emacs/my-org-daily/"
"h:/emacs/my-org-note/")))
(when *is-mac*
(setq org-agenda-files '("~/org/my-org-daily"
"~/org/my-org-note/")))
(when *is-linux*
(setq org-agenda-files '("~/org/my-org-daily/"
"~/org/my-org-note/")))
(setq org-agenda-span 'day)
(setq org-default-priority ?C)
(setq org-agenda-skip-function-global
'(org-agenda-skip-entry-if 'todo '("COMMENT")))
(global-cns-mode-enable-in-buffer))))
;; org-ql
(use-package org-ql
@@ -238,7 +246,6 @@
(org-ql-sort '(start-time))
(org-super-agenda-groups
'((:auto-ts t)))))))
("qa" "all TODO entries"
((org-ql-block '(and (not (done)) (todo))
((org-ql-block-header "all TODOs")
@@ -301,20 +308,10 @@
(setq org-bookmark-names-plist nil)
;; 批量调整表格
(defun org-table-align-all ()
"Ajust all table in current buffer."
(interactive)
(save-excursion
(goto-char (point-min))
(org-table-map-tables 'org-table-align t)))
;; hugo
;; 安装ox-hugo
(use-package ox-hugo)
(with-eval-after-load 'org-capture
(defun org-hugo-new-subtree-post-capture-template ()
"Returns `org-capture' template string for new Hugo post.

View File

@@ -191,12 +191,8 @@ targets."
'embark-collect-mode-hook
#'consult-preview-at-point-mode))))
;; nerd-icon
;; (use-package nerd-icons)
;; 启用savehist保存命令顺序
(use-package savehist
;; :hook (after-init . savehist-mode)
:init (setq enable-recursive-minibuffers t
history-length 50
savehist-additional-variables '(mark-ring
@@ -272,13 +268,6 @@ targets."
;; consult-flycheck
(use-package consult-flycheck)
;; markdown
(use-package markdown-mode
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown")
:bind (:map markdown-mode-map
("C-c C-e" . markdown-do)))
;; vterm
(unless *is-windows*
(use-package vterm))
@@ -286,6 +275,24 @@ targets."
;; general
(use-package general)
;; perspective
(use-package perspective
:bind
("C-x M-b" . persp-list-buffers) ; or use a nicer switcher, see below
:custom
(persp-mode-prefix-key (kbd "C-c p")) ; pick your own prefix key here
:init
(persp-mode)
:config
(setq persp-switch-to-buffer-behavior 'switch)
(with-eval-after-load 'consult
(consult-customize consult-source-buffer :hidden t :default nil)
(add-to-list 'consult-buffer-sources persp-consult-source))
(setq switch-to-prev-buffer-skip
(lambda (win buff bury-or-kill)
(not (persp-is-current-buffer buff))))
(setq persp-initial-frame-name "desktop"))
(provide 'init-package)
;;; init-package.el ends here

41
lisp/init-prog.el Normal file
View File

@@ -0,0 +1,41 @@
;;; init.el --- init.el -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; tree-sitter
(use-package treesit-auto
:demand t
:config
(setq treesit-auto-install 'prompt)
(global-treesit-auto-mode)
(setq treesit-font-lock-level 4))
;; lua
(use-package lua-ts-mode
:mode ("\\.lua\\'" . lua-ts-mode)
:config
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-ts-mode)))
;; ahk
(use-package ahk-mode)
;; scheme
(use-package geiser
:config
(with-eval-after-load 'geiser
(setq geiser-default-implementation 'guile)))
;; markdown
(use-package markdown-mode
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown")
:bind (:map markdown-mode-map
("C-c C-e" . markdown-do)))
(use-package geiser-guile)
(provide 'init-prog)
;;; init-prog.el ends here

View File

@@ -5,10 +5,13 @@
;;; Code:
;; mac自动全屏
(unless *is-windows*
(cond
(*is-mac*
(toggle-frame-fullscreen)
(global-unset-key (kbd "<f12>"))
(global-set-key (kbd "<f12>") 'toggle-frame-fullscreen))
(*is-linux*
(toggle-frame-fullscreen)))
;; 配置备份文件和自动保存文件目录
(setq backup-directory-alist
@@ -31,15 +34,14 @@
;; 关闭提示音
(setq ring-bell-function 'ignore)
;; 同步scoop目录
(when *is-windows*
;; 同步包管理器目录
(cond
(*is-windows*
(add-to-list 'exec-path (expand-file-name "H/appppppppppp/scoop/apps/"))
(setenv "PATH" (concat (expand-file-name "H/appppppppppp/scoop/apps/") ";" (getenv "PATH"))))
;; 同步brew目录
(when *is-mac*
(*is-mac*
(add-to-list 'exec-path (expand-file-name "/opt/homebrew/bin/"))
(setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH"))))
(setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH")))))
;; 当文件被外部修改时自动刷新
(global-auto-revert-mode 1)
@@ -80,6 +82,7 @@
;; ibuffer
(setq ibuffer-default-sorting-mode 'filename)
;; 关闭native compile警告
(setq native-comp-async-warnings-errors-kind 'silent)
;; short anwser

View File

@@ -16,9 +16,6 @@
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8)))
;; 安装autothemer
(use-package autothemer)
;; 预览所有可用emacs颜色
(defun my-color-picker ()
"Pick a color with preview."
@@ -61,13 +58,6 @@
;; (use-package color-theme-modern)
(use-package naysayer-theme)
;; modeline
;; (use-package smart-mode-line
;; :config
;; (setq sml/no-confirm-load-theme t)
;; ;; sml/theme 'respectful)
;; (sml/setup))
;; (use-package simple-modeline
;; :init (simple-modeline-mode)
;; :config
@@ -110,68 +100,6 @@
;; 显示行号列号
(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)))))
;; 设置字体大小和字重变量
(when *is-windows*
(defvar tenon-font-size 125
"默认字体大小")
(defvar tenon-font-weight 'light
"默认字重选项有ultra-lightlightnormalmediumsemiboldbold"))
(when *is-mac*
(defvar tenon-font-size 160
"默认字体大小")
(defvar tenon-font-weight 'light
"默认字重选项有ultra-lightlightnormalmediumsemiboldbold"))
(when *is-linux*
(defvar tenon-font-size 125
"默认字体大小")
(defvar tenon-font-weight 'normal
"默认字重选项有ultra-lightlightnormalmediumsemiboldbold"))
;; 定义函数
;;;###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") ; 英文字体
@@ -182,8 +110,8 @@
;; 安装cnfonts脚本用于修复中英文对齐
(use-package cnfonts
:init
(cnfonts-mode 1)
:hook
(after-init-hook . cnfonts-mode)
:config
(cnfonts--select-profile "profile1"))

View File

@@ -102,9 +102,6 @@
(delete-window window)))))
(advice-add #'keyboard-quit :before #'popper-close-window-hack)))
;; ace-window
;; (use-package ace-window)
;; es-windos快速管理窗口
(use-package es-windows)

View File

@@ -1,26 +0,0 @@
;;; init-workspace.el --- workspace -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package perspective
:bind
("C-x M-b" . persp-list-buffers) ; or use a nicer switcher, see below
:custom
(persp-mode-prefix-key (kbd "C-c p")) ; pick your own prefix key here
:init
(persp-mode)
:config
(setq persp-switch-to-buffer-behavior 'switch)
(with-eval-after-load 'consult
(consult-customize consult-source-buffer :hidden t :default nil)
(add-to-list 'consult-buffer-sources persp-consult-source))
(setq switch-to-prev-buffer-skip
(lambda (win buff bury-or-kill)
(not (persp-is-current-buffer buff))))
(setq persp-initial-frame-name "desktop"))
(provide 'init-workspace)
;;; init-workspace.el ends here