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-message
nil 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-message
nil 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