From 9b35fe089932feaae5d60e3393c733906b639074 Mon Sep 17 00:00:00 2001 From: e2hang <2099307493@qq.com> Date: Mon, 22 Dec 2025 15:15:47 +0800 Subject: [PATCH] emacs --- init.el | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 init.el diff --git a/init.el b/init.el new file mode 100644 index 0000000..d44ab1f --- /dev/null +++ b/init.el @@ -0,0 +1,70 @@ +(require 'package) +;; +(setq package-archives '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/") + ("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/") + ("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/"))) + +;; +(package-initialize) + +;; +(unless package-archive-contents + (package-refresh-contents)) + +;; +(unless (package-installed-p 'company) + (package-install 'company)) + +;; +(add-hook 'after-init-hook 'global-company-mode) + +;; +(setq company-minimum-prefix-length 5) ; +(setq company-idle-delay 0.0) ; +(setq company-show-quick-access t) ; + + +;; 1. 解决中文乱码问题(非常重要) +(set-language-environment "UTF-8") +(set-terminal-coding-system 'utf-8) +(set-keyboard-coding-system 'utf-8) +(set-selection-coding-system 'utf-8) +(set-buffer-file-coding-system 'utf-8) +(set-default-coding-systems 'utf-8) +(modify-coding-system-alist 'process "*" 'utf-8) + +;; 2. 设置默认字体(比如你喜欢的 Consolas) +(set-face-attribute 'default nil :family "Consolas" :height 160) + +;; 3. 关闭烦人的启动画面和工具栏 +(setq inhibit-startup-screen t) ; 关闭启动画面 +;;(tool-bar-mode -1) ; 关闭工具栏 +;;(scroll-bar-mode -1) ; 关闭滚动条(看个人喜好) + +;; 开启行号 +(global-display-line-numbers-mode t) +;; 不开启eshell的 +(add-hook 'eshell-mode-hook (lambda () (display-line-numbers-mode -1))) +;;自动匹配括号 +(electric-pair-mode t) +;;任何模式下 +(setq electric-pair-preserve-balance t) + + +;; 4. 快速打开配置文件(方便以后随时修改) +(defun open-init-file () + (interactive) + (find-file "~/.emacs.d/init.el")) +(global-set-key (kbd "") 'open-init-file) ; 按 F5 快速改配置 +(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. + '(package-selected-packages nil)) +(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. + )