我的.emacs(Ubuntu版)(二十二)

2024-05-08 00:38
文章标签 ubuntu 二十二 emacs

本文主要是介绍我的.emacs(Ubuntu版)(二十二),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.版本一 

(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("elpa" . "http://elpa.gnu.org/packages/"))(ansi-color-for-comint-mode-on)
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(load-theme 'tsdh-dark)
(require 'auto-complete)
(global-auto-complete-mode t)
(global-set-key (kbd "C-SPC") nil);;去掉工具条
(tool-bar-mode 0)
;;去掉菜单栏
(menu-bar-mode 0)(load-file "~/.emacs.d/site-lisp/imenu-list.el")
(global-set-key [f9] #'imenu-list-smart-toggle)
;;去掉启动界面
(setq inhibit-startup-message t);;打开文件默认只读模式
(defun read-only-setup () (read-only-mode))
(add-hook 'find-file-hook #'read-only-setup);;neotree
(add-to-list 'load-path "~/.emacs.d/site-lisp/neotree")
;;(load-file "~/.emacs.d/site-lisp/neotree/teotree.el")
(require 'neotree)
(global-set-key [f7] 'hexl-mode)
(global-set-key [f8] 'neotree-refresh)
(global-set-key [f10] 'neotree-toggle)
(global-set-key [f12] 'cua-mode);;cscope
(require 'xcscope)
(setq cscope-do-not-update-database t)
(global-set-key (kbd "M-1") 'cscope-find-egrep-pattern)
(global-set-key (kbd "M-2") 'cscope-find-this-file)
(global-set-key (kbd "M-3") 'cscope-index-files)
(global-set-key (kbd "M-4") 'cscope-find-this-symbol)
(global-set-key (kbd "M-5") 'cscope-find-global-definition)
(global-set-key (kbd "M-6") 'cscope-pop-mark)
(global-set-key [f1] 'whitespace-newline-mode);自动清除行位空格
(global-set-key [f2] 'delete-trailing-whitespace)
(global-set-key [f3] 'find-name-dired)
(global-set-key [f4] 'grep-find)
(global-set-key [f5] 'compile)
(global-set-key [(f6)] 'replace-regexp)
(setq x-select-enable-clipboard t)
(setq mouse-yank-at-point t)
(global-hl-line-mode 1)(require'linum)
(global-linum-mode t)
(setq column-number-mode t)(add-hook 'comint-output-filter-functions'comint-watch-for-password-prompt)(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)(column-number-mode t)
(setq default-tab-width 2)
(setq indent-tabs-mode nil);; add there directory before same file
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(global-set-key (kbd "C-j") 'goto-line)
(electric-pair-mode t)(setq make-backup-files nil)
;; 设定不产生备份文件
(setq-default make-backup-files nil)
;关闭自动保存模式
(setq auto-save-mode nil)
;不生成 #filename# 临时文件
(setq auto-save-default nil);;括号匹配
(show-paren-mode t)
(setq show-paren-style 'parentheses);;双重补全,好用的很呐
(global-set-key (kbd "M-/") 'hippie-expand);;括号自动补全
(electric-pair-mode 1)
(setq electric-pair-pairs '((?\" . ?\")(?\{ . ?\})) );;Command line(No Gui)
(setq x-select-enable-clipboard t)
(unless window-system(when (getenv "DISPLAY")(defun xsel-cut-function (text &optional push)(with-temp-buffer(insert text)(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))(defun xsel-paste-function()(let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))(unless (string= (car kill-ring) xsel-output)xsel-output )))(setq interprogram-cut-function 'xsel-cut-function)(setq interprogram-paste-function 'xsel-paste-function)));;窗口全屏 
(defun my-fullscreen () (interactive) (x-send-client-messagenil 0 nil "_NET_WM_STATE" 32'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
(my-fullscreen);;Or full screen : 非全屏
;;(add-to-list 'default-frame-alist '(fullscreen . maximized))

2.版本二(2023.3.19版)

(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("elpa" . "http://elpa.gnu.org/packages/"))(ansi-color-for-comint-mode-on)
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(load-theme 'tsdh-dark)
(require 'auto-complete)
(global-auto-complete-mode t)
(global-set-key (kbd "C-SPC") nil)(with-eval-after-load 'company (company-ctags-auto-setup));;highlight-beyond-fill 80+
(add-to-list 'load-path "~/.emacs.d/site-lisp/highlight-beyond-fill")
(require 'highlight-beyond-fill-column);;去掉工具条
(tool-bar-mode 0)
;;去掉菜单栏
(menu-bar-mode 0)(load-file "~/.emacs.d/site-lisp/imenu-list.el")
(global-set-key [f9] #'imenu-list-smart-toggle)
;;去掉启动界面
(setq inhibit-startup-message t);;打开文件默认只读模式
(defun read-only-setup () (read-only-mode))
(add-hook 'find-file-hook #'read-only-setup);;记录我们每次调用 M-x 时输入的命令历史,然后每次将最常用的显示在前面
;;amx-mode
(use-package amx:ensure t:init (amx-mode));;mwin: 优化C-a和C-e
(use-package mwim:ensure t:bind("C-a" . mwim-beginning-of-code-or-line)("C-e" . mwim-end-of-code-or-line));;ace-window:: 多窗口时,C-x o 重新绑定ace-window,为每个window编号跳转.
(use-package ace-window:ensure t:bind (("C-x o" . 'ace-window)));;undo-tree
(use-package undo-tree:ensure t:init (global-undo-tree-mode))(setq sml/no-confirm-load-theme t)
(use-package smart-mode-line:ensure t:init (sml/setup))(use-package good-scroll:ensure t:if window-system          ; 在图形化界面时才使用这个插件:init (good-scroll-mode))(use-package which-key:ensure t:init (which-key-mode))(use-package avy:ensure t:bind(("M-j" . avy-goto-char-timer)))(use-package highlight-symbol:ensure t:init (highlight-symbol-mode):bind ("C-." . highlight-symbol));;Or
;;(add-hook 'find-file-hook 'read-only-mode);;swiper快速搜索(好用)
global-set-key (kbd "C-s") 'swiper);;counsel快速搜索
;;(global-set-key (kbd "C-s") 'counsel-grep);;counsel mode
(ivy-mode t)
(counsel-mode t)
(setq ivy-use-virtual-buffers t)
(setq ivy-use-selectable-prompt t)
(setq enable-recursive-minibuffers t)
(setq ivy-count-format "(%d/%d) ")
(setq search-default-mode #'char-fold-to-regexp);;搜索最近访问文件
;;(global-set-key (kbd "C-x b") 'ivy-switch-buffer)
(global-set-key (kbd "C-x b") 'counsel-switch-buffer);;搜索文件
(global-set-key (kbd "C-x C-f") 'counsel-find-file);;查看历史搜索记录
;;(global-set-key (kbd "C-r") 'counsel-grep-or-swiper)
;;(global-set-key (kbd "C-r") 'counsel-find-file)
(global-set-key (kbd "C-r") 'counsel-recentf)(defun copy-all-dir ()"copy dir path."(interactive)(message "dired-copy-filename-as-kill 0")(dired-copy-filename-as-kill 0))(define-key dired-mode-map (kbd "w") 'copy-all-dir);;neotree
(add-to-list 'load-path "~/.emacs.d/site-lisp/neotree")
(require 'neotree)
(global-set-key [f7] 'hexl-mode)
(global-set-key [f8] 'neotree-toggle)
(global-set-key [f10] 'neotree-toggle)
(global-set-key [f12] 'cua-mode)(global-set-key (kbd "C-,") 'neotree-refresh)
;;(define-key key-translation-map (kbd "g") (kbd "<f10>"));;Or
;;(global-auto-revert-mode 1)
;;目录只读
(defun refresh-dired ()(interactive)(neotree-refresh)(auto-revert-mode);;(delete-other-windows 1)
;;  (delete-windows 0))
;;(global-set-key [f10] 'refresh-dired);;将当前行移动到最上端.
(defun go-top ()"Go to front line."(interactive)(message "recenter-top-bottom 0");;(universal-argument)(recenter-top-bottom 0));;cscope
(require 'xcscope)
(setq cscope-do-not-update-database t)
(global-set-key (kbd "M-1") 'cscope-find-egrep-pattern)
(global-set-key (kbd "M-2") 'cscope-find-this-file)
(global-set-key (kbd "M-3") 'cscope-index-files)
(global-set-key (kbd "M-4") 'cscope-find-this-symbol)
(global-set-key (kbd "M-5") 'cscope-find-global-definition)
(global-set-key (kbd "M-6") 'cscope-pop-mark)
(global-set-key (kbd "M-7") 'cscope-prev-symbol)
(global-set-key (kbd "M-8") 'cscope-next-symbol)
(global-set-key (kbd "M-9") 'go-top)(global-set-key [f1] 'whitespace-newline-mode);自动清除行位空格
(global-set-key [f2] 'delete-trailing-whitespace)
;;(global-set-key [f3] 'find-name-dired)
(global-set-key [f3] 'front-insert-linenumber)
(global-set-key [f4] 'grep-find)
(global-set-key [f5] 'compile)
(global-set-key [(f6)] 'replace-regexp)
(setq x-select-enable-clipboard t)
(setq mouse-yank-at-point t)
(global-hl-line-mode 1);;行号显示
(require 'linum)
(global-linum-mode t)
(setq column-number-mode t);; ;;行号显示
;; (require 'hlinum)
;; (hlinum-activate)
;; (setq column-number-mode t)(add-hook 'comint-output-filter-functions'comint-watch-for-password-prompt)(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)(column-number-mode t)
(setq default-tab-width 2)
(setq indent-tabs-mode nil);; add there directory before same file
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(global-set-key (kbd "C-j") 'goto-line)
(electric-pair-mode t)(setq make-backup-files nil)
;; 设定不产生备份文件
(setq-default make-backup-files nil)
;关闭自动保存模式
(setq auto-save-mode nil)
;不生成 #filename# 临时文件
(setq auto-save-default nil);;括号匹配
(show-paren-mode t)
(setq show-paren-style 'parentheses);;双重补全,好用的很呐
(global-set-key (kbd "M-/") 'hippie-expand);;括号自动补全
(electric-pair-mode 1)
(setq electric-pair-pairs '((?\" . ?\")(?\{ . ?\})) );;Command line(No Gui)
(setq x-select-enable-clipboard t)
(unless window-system(when (getenv "DISPLAY")(defun xsel-cut-function (text &optional push)(with-temp-buffer(insert text)(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))(defun xsel-paste-function()(let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))(unless (string= (car kill-ring) xsel-output)xsel-output )))(setq interprogram-cut-function 'xsel-cut-function)(setq interprogram-paste-function 'xsel-paste-function)));;窗口全屏 
(defun my-fullscreen () (interactive) (x-send-client-messagenil 0 nil "_NET_WM_STATE" 32'(2 "_NET_WM_STATE_FULLSCREEN" 0)));;(my-fullscreen)(defun fullscreen ()(interactive)(set-frame-parameter nil 'fullscreen(if (frame-parameter nil 'fullscreen) nil 'fullboth)))(fullscreen);;(add-to-list 'default-frame-alist '(fullscreen . maximized))(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-safe-themes'("3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" default))'(display-time-mode t)'(package-selected-packages'(rainbow-delimiters highlight-symbol tiny dashboard which-key good-scroll smart-mode-line undo-tree mwim ace-window amx nlinum hlinum fd-dired ripgrep counsel fzf swiper markdown-mode vmd-mode cmake-mode gnu-elpa-keyring-update gnu-elpa company-ycmd))'(show-paren-mode t)'(tool-bar-mode 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.'(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 128 :width normal)))))

3.版本三(2023.4.6)

(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("elpa" . "http://elpa.gnu.org/packages/"))(ansi-color-for-comint-mode-on)
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(load-theme 'tsdh-dark)
(require 'auto-complete)
(global-auto-complete-mode t)
(global-set-key (kbd "C-SPC") nil)
(with-eval-after-load 'company (company-ctags-auto-setup));;ert
(require 'ert);;gtags
(load-file "~/.emacs.d/site-lisp/gtags.el")
(require 'ggtags)
(setenv "GTAGSLABEL" "pygments")
(setq ggtags-global-mode 1)
(add-hook 'c-mode-common-hook(lambda ()(when (derived-mode-p 'c-mode 'c++-mode 'java-mode 'asm-mode)(ggtags-mode 1))))(add-hook 'gtags-select-mode-hook'(lambda ()(setq hl-line-face 'underline)(hl-line-mode 1)))(add-hook 'dired-mode-hook 'ggtags-mode)
(add-hook 'go-mode-hook 'ggtags-mode)
(add-hook 'python-mode-hook 'ggtags-mode)
; ggtags integrate Imenu
(setq-local imenu-create-index-function #'ggtags-build-imenu-index)
; Customization
(setq gtags-suggested-key-mapping t)
(setq gtags-auto-update t);;cflow
(require 'cflow-mode)
(defvar cmd nil nil)
(defvar cflow-buf nil nil)
(defvar cflow-buf-name nil nil)(defun yyc/cflow-function (function-name)"Get call graph of inputed function. "(interactive "sFunction name:\n")(interactive (list (car (senator-jump-interactive "Function name: "nil nil nil))))(setq cmd (format "cflow  -b --main=%s %s" function-name buffer-file-name))(setq cflow-buf-name (format "**cflow-%s:%s**"(file-name-nondirectory buffer-file-name)function-name))(setq cflow-buf (get-buffer-create cflow-buf-name))(set-buffer cflow-buf)(setq buffer-read-only nil)(erase-buffer)(insert (shell-command-to-string cmd))(pop-to-buffer cflow-buf)(goto-char (point-min))(cflow-mode));;cedet解析代码定义位置
(semantic-mode 1)
(global-ede-mode 1)
(global-semanticdb-minor-mode t)	 ;;缓存解析过的源代码的结果,以便以后可以使用
(global-semantic-idle-scheduler-mode t)	 ;;emacs空闲时分析源代码
(global-semantic-idle-summary-mode t)	 ;;对当前位点处符号,显示分析出来的结果的摘要
(global-semantic-idle-completions-mode t);;代码补全功能,可以使用命令进行选择
(global-semantic-decoration-mode t)	 ;;顾名思义,使用不同的显示风格来显示分析出来的不同结果
(global-semantic-highlight-edits-mode t)
(global-semantic-show-parser-state-mode t)
(global-semantic-highlight-func-mode t)	 ;;高亮函数或者标签的声明行
(global-semantic-stickyfunc-mode t)	 ;;在文本的最上层显示函数的声明信息
(global-semantic-mru-bookmark-mode t)	 ;;保存使用过的所有tag,mru是最多最近使用的意思;;multiple-cursors
(require 'multiple-cursors);;x-send-keystrokes
(require 'cl-lib);;highlight-beyond-fill 80+
(add-to-list 'load-path "~/.emacs.d/site-lisp/highlight-beyond-fill")
(require 'highlight-beyond-fill-column);;去掉工具条
(tool-bar-mode 0)
;;去掉菜单栏
(menu-bar-mode 0)(load-file "~/.emacs.d/site-lisp/imenu-list.el")
(global-set-key [f9] #'imenu-list-smart-toggle)
;;去掉启动界面
(setq inhibit-sta

这篇关于我的.emacs(Ubuntu版)(二十二)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/968843

相关文章

如何在Ubuntu 24.04上部署Zabbix 7.0对服务器进行监控

《如何在Ubuntu24.04上部署Zabbix7.0对服务器进行监控》在Ubuntu24.04上部署Zabbix7.0监控阿里云ECS服务器,需配置MariaDB数据库、开放10050/1005... 目录软硬件信息部署步骤步骤 1:安装并配置mariadb步骤 2:安装Zabbix 7.0 Server

Ubuntu如何分配​​未使用的空间

《Ubuntu如何分配​​未使用的空间》Ubuntu磁盘空间不足,实际未分配空间8.2G因LVM卷组名称格式差异(双破折号误写)导致无法扩展,确认正确卷组名后,使用lvextend和resize2fs... 目录1:原因2:操作3:报错5:解决问题:确认卷组名称​6:再次操作7:验证扩展是否成功8:问题已解

Ubuntu设置程序开机自启动的操作步骤

《Ubuntu设置程序开机自启动的操作步骤》在部署程序到边缘端时,我们总希望可以通电即启动我们写好的程序,本篇博客用以记录如何在ubuntu开机执行某条命令或者某个可执行程序,需要的朋友可以参考下... 目录1、概述2、图形界面设置3、设置为Systemd服务1、概述测试环境:Ubuntu22.04 带图

Ubuntu上手动安装Go环境并解决“可执行文件格式错误”问题

《Ubuntu上手动安装Go环境并解决“可执行文件格式错误”问题》:本文主要介绍Ubuntu上手动安装Go环境并解决“可执行文件格式错误”问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未... 目录一、前言二、系统架构检测三、卸载旧版 Go四、下载并安装正确版本五、配置环境变量六、验证安装七、常见

ubuntu如何部署Dify以及安装Docker? Dify安装部署指南

《ubuntu如何部署Dify以及安装Docker?Dify安装部署指南》Dify是一个开源的大模型应用开发平台,允许用户快速构建和部署基于大语言模型的应用,ubuntu如何部署Dify呢?详细请... Dify是个不错的开源LLM应用开发平台,提供从 Agent 构建到 AI workflow 编排、RA

ubuntu系统使用官方操作命令升级Dify指南

《ubuntu系统使用官方操作命令升级Dify指南》Dify支持自动化执行、日志记录和结果管理,适用于数据处理、模型训练和部署等场景,今天我们就来看看ubuntu系统中使用官方操作命令升级Dify的方... Dify 是一个基于 docker 的工作流管理工具,旨在简化机器学习和数据科学领域的多步骤工作流。

如何在Ubuntu上安装NVIDIA显卡驱动? Ubuntu安装英伟达显卡驱动教程

《如何在Ubuntu上安装NVIDIA显卡驱动?Ubuntu安装英伟达显卡驱动教程》Windows系统不同,Linux系统通常不会自动安装专有显卡驱动,今天我们就来看看Ubuntu系统安装英伟达显卡... 对于使用NVIDIA显卡的Ubuntu用户来说,正确安装显卡驱动是获得最佳图形性能的关键。与Windo

双系统电脑中把Ubuntu装进外接移动固态硬盘的全过程

《双系统电脑中把Ubuntu装进外接移动固态硬盘的全过程》:本文主要介绍如何在Windows11系统中使用VMware17创建虚拟机,并在虚拟机中安装Ubuntu22.04桌面版或Ubunt... 目录一、首先win11中安装vmware17二、磁盘分区三、保存四、使用虚拟机进行系统安装五、遇见的错误和解决

CentOS和Ubuntu系统使用shell脚本创建用户和设置密码

《CentOS和Ubuntu系统使用shell脚本创建用户和设置密码》在Linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设置密码,本文写了一个shell... 在linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设

Ubuntu中远程连接Mysql数据库的详细图文教程

《Ubuntu中远程连接Mysql数据库的详细图文教程》Ubuntu是一个以桌面应用为主的Linux发行版操作系统,这篇文章主要为大家详细介绍了Ubuntu中远程连接Mysql数据库的详细图文教程,有... 目录1、版本2、检查有没有mysql2.1 查询是否安装了Mysql包2.2 查看Mysql版本2.