Files
.emacs.d/lisp/init-startup.el
User e2a352709c chore(config): Refactor Emacs config for cross-platform compatibility
Add Android/Termux support with `*is-android*` constant and
conditional GUI/terminal initialization. Remove maximized frame
defaults and custom.el. Replace corfu with corfu-terminal in
TTY. Add god-mode to terminal config with line number sync. Update
org agenda to use org-ql blocks with super-agenda grouping. Switch
solarized-theme to fork. Clean up redundant functions and unify
keyboard bindings across environments.
2026-05-18 20:46:26 +08:00

114 lines
2.7 KiB
EmacsLisp

;;; init-startup.el --- startup settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; mac自动全屏
(cond
(*is-mac*
(set-frame-parameter nil 'fullscreen 'fullscreen)
(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
`((".*" . ,(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)))
;; 开启水平滚动
(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/"))
(setenv "PATH" (concat (expand-file-name "H/appppppppppp/scoop/apps/") ";" (getenv "PATH"))))
(*is-mac*
(add-to-list 'exec-path (expand-file-name "/opt/homebrew/bin/"))
(setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH")))))
;; 当文件被外部修改时自动刷新
(global-auto-revert-mode 1)
;; 开启recent file mode
(when (display-graphic-p)
(recentf-mode)
(setq recentf-max-saved-items 30)) ;; 最大保存数量
;; 启用select delete
(delete-selection-mode)
;; 启用winner mode
(winner-mode)
;; 自定义scratch
(setq initial-scratch-message
"")
(defun my/scratch-set-mode (&rest _)
(when (eq major-mode 'fundamental-mode)
(funcall initial-major-mode)))
(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
(add-to-list 'electric-pair-pairs '(?\~ . ?\~)))
;; 关闭native compile警告
(setq native-comp-async-warnings-errors-kind 'silent)
;; short anwser
(if (boundp 'use-short-answers)
(setq use-short-answers t)
(fset 'yes-or-no-p 'y-or-n-p))
;; 移动到垃圾桶
(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)
(provide 'init-startup)
;;; init-startup.el ends here