我的Emacs配置

简介: 这是一份高度定制化的 Emacs 配置文件,采用 use-package 声明式管理。启用 Dracula 主题、Fira Code 字体,集成 Eglot(C/C++)、SLIME(Common Lisp)、xcscope(C 代码导航)及 clang-format 自动格式化,配备 Company 补全、括号高亮、行号显示等现代编辑功能,兼顾效率与美观。(239字)

(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.

'(column-number-mode t)

'(custom-enabled-themes '(dracula))

'(custom-safe-themes

  '("2d74de1cc32d00b20b347f2d0037b945a4158004f99877630afc034a674e3ab7" default))

'(package-selected-packages

  '(xcscope clang-format format-all eglot company-quickhelp-terminal company-quickhelp company-box use-package slime-company dracula-theme gnu-elpa-keyring-update slime smex))

'(show-paren-mode t))

(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.

'(default ((t (:family "Fira Code" :foundry "CTDB" :slant normal :weight normal :height 113 :width normal)))))

(require 'use-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) ;; You might already have this line



;;关闭启动页面

(setq inhibit-startup-message t)

(setq gnus-inhibit-startup-message t)

;;设置光标为|

(setq-default cursor-type 'bar)


;; 在窗口中显示行号

(global-linum-mode 1)        ;; 总是显示行号


;; 显示光标当前所在的行和列

(column-number-mode t)


;; 显示匹配的括号

(show-paren-mode t)

(setq show-paren-style 'parentheses)


;; 内置的智能自动补全括号

(electric-pair-mode t)


;; 鼠标自动避开光标

(mouse-avoidance-mode 'animate)

;; 将确定时输入的关键字 yes 和 no 替换为单字母 y 和 n

(fset 'yes-or-no-p 'y-or-n-p)


;; 不生成备份文件

(setq make-backup-files nil)

;;检查gnu签名,nil表示不检查

(setq package-check-signature 'allow-unsigned)


;;company

(use-package company

 :ensure t

 :hook (after-init . global-company-mode) ;; 全局启用 company-mode

 :config

 (setq company-idle-delay 0.2               ;; 补全弹出延迟

       company-minimum-prefix-length 2      ;; 触发补全的最小字符数

       company-tooltip-align-annotations t)) ;; 对齐注释


;;company-quickhelp:用来弹出说明文档

(use-package company-quickhelp

 :ensure t

 :hook (company-mode . company-quickhelp-mode)

 :config

 (setq company-quickhelp-delay 0.2))


;;clangd:C/C++代码补全

(require 'eglot)

(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))

(add-hook 'c-mode-hook 'eglot-ensure)

(add-hook 'c++-mode-hook 'eglot-ensure)


;;cscope:C代码阅读

(require 'xcscope)

(cscope-setup)

;; 打开cscope时不更新,提高索引速度

(setq cscope-do-not-update-database t)

(setq cscope-option "-q")


;;sbcl

(setq inferior-lisp-program "sbcl")

;;slime-company

(slime-setup '(slime-fancy slime-company))

(use-package slime-company

 :after (slime company)

 :config (setq slime-company-completion 'fuzzy

               slime-company-after-completion 'slime-company-just-one-space))

(define-key company-active-map (kbd "\C-n") 'company-select-next)

(define-key company-active-map (kbd "\C-p") 'company-select-previous)

(define-key company-active-map (kbd "\C-d") 'company-show-doc-buffer)

(define-key company-active-map (kbd "M-.") 'company-show-location)


;;clang-format:C/C++脚本格式化

(use-package clang-format

 :ensure t  ;; 自动从 MELPA 安装

 :config

 (setq clang-format-executable (executable-find "clang-format")

       clang-format-style "file")  ;; "file" 表示使用 .clang-format 配置文件  

 ;; C脚本保存时自动格式化

(add-hook 'c-mode-common-hook

           (lambda ()

             (add-hook 'before-save-hook 'clang-format-buffer nil t)

             ;; 只在 C/C++ 模式中绑定 C-c f

             (local-set-key (kbd "C-c f") 'clang-format-buffer)))

 ;; lisp脚本保存时自动格式化

(add-hook 'lisp-mode-hook

         (lambda ()

           (add-hook 'before-save-hook

                    (lambda ()

                      (save-excursion

                        (pp-buffer)  ;; 这会自动美化整个缓冲区

                        (indent-region (point-min) (point-max))))

                    nil t)

           (local-set-key (kbd "C-c f")

                         (lambda ()

                           (interactive)

                           (save-excursion

                             (pp-buffer)

                             (indent-region (point-min) (point-max)))))))


;; ========== 全局缩进设置 ==========

;(setq lisp-indent-offset 2)        ;; Lisp 缩进 2 空格

(setq indent-tabs-mode nil)        ;; 统一使用空格

 )

目录
相关文章
|
存储 开发工具
Emacs+SBCL+Slime+CHLS(QuickLisp)
Emacs+Slime+CHLS(QuickLisp)
886 7
|
存储 缓存 安全
【cmake 生成配置文件】CMake与现代C++:配置文件宏的深度探索与应用
【cmake 生成配置文件】CMake与现代C++:配置文件宏的深度探索与应用
717 0
|
7月前
|
机器学习/深度学习 人工智能 算法
脑肿瘤识别目标检测数据集(1200张图片已划分、已标注)| AI训练适用于目标检测任务
本数据集含1200张高质量脑部MRI影像,已精准标注“阴性/阳性”二分类标签,并划分训练集与验证集,适用于YOLO、ResNet等模型的脑肿瘤自动识别与辅助诊断任务,结构规范、即取即用。
|
9月前
|
存储 Shell Linux
玩转Linux Shell数组(从零开始掌握Shell数组初始化技巧)
本教程详解Linux Shell数组初始化,涵盖空数组声明、赋值初始化、指定索引、命令输出填充等方法,助你掌握Bash数组基本操作,提升脚本编写效率,适合Shell初学者快速入门。
|
7月前
|
机器学习/深度学习 数据采集 算法
基于YOLOv8的桥梁结构(轴承,封板端部,三角撑板连接,面外加劲板)智能识别(中英文双版) | 附完整源码与效果演示
本文介绍了一种基于YOLOv8的桥梁结构识别系统,该系统能够自动识别桥梁中的关键结构部件,包括轴承、封板端部、三角撑板连接和面外加劲板等。通过深度学习技术,实现了对桥梁结构的快速、准确检测,为桥梁健康监测和维护提供了有力的技术支撑。
|
7月前
|
缓存 JSON 前端开发
心里美商品详情页前端性能优化实战
心里美生鲜电商商品详情页前端性能优化实战:针对生鲜图片(8–12MB)、溯源多媒体、促销频繁更新、评价富文本等核心瓶颈,创新实现品类自适应图像优化器、新鲜度感知缓存、分层加载与智能预取,LCP↓54%、CLS↓71%,切面图查看率+191%,显著提升弱网与移动端体验。(239字)
|
机器学习/深度学习 人工智能 自然语言处理
Hugging Face 的应用
Hugging Face 是一家专注于开发机器学习应用工具的公司,以其用于自然语言处理的 Transformers 库而闻名,同时提供了一个平台让用户分享机器学习模型和数据集。Transformers 库支持多种任务,如文本分类、生成、总结等,并兼容 PyTorch、TensorFlow 等框架。Hugging Face 还推出了 Text Generation Inference 工具包,用于高效部署大规模语言模型。在国内,百度千帆和魔搭社区等平台也在提供类似的服务和支持。
|
12月前
|
存储 监控 API
Python datetime模块:时间处理的瑞士军刀
免费Python编程教程,深入讲解datetime模块核心用法:时间对象创建、格式化、运算及时区处理,附实战案例与避坑指南,助你高效掌握Python时间操作。链接:https://pan.quark.cn/s/2c17aed36b72
1238 0
|
传感器 人工智能 算法
智能硬件创新:产品技术双驱,不玩 AI 硬凑
在智能硬件快速发展的今天,仅靠“AI+硬件”的简单叠加难以实现真正创新。产品创新需以用户需求为核心,从设计、功能到体验全方位优化;技术创新则通过新材料、新工艺和新算法提升性能、降低成本。两者深度融合、双轮驱动,方能打造卓越的智能硬件。例如苹果iPhone与大疆无人机,均凭借产品和技术的协同突破成为行业标杆。企业应避免常见“坑”,如用户体验不佳、技术难度高和成本控制难,以真创新引领市场。联系法思诺,探索更多创新可能!
562 0