emacs25配置文件.emacs

松昱
2023-12-01

直接上code:

;; C-h k 
;; to see the keybonding of the key you press
;; so we can thought the old keybongding to create new keybongding

;; C-x 1 : to keep current frame, close all the other frames 
;; C-x 0 : to close current frame
;; C-x o : to move to next frame
;; C-x 2 : to split a new frame vertically
;; C-x 3 : to split a new frame horizontally

;; global short cut set

;; 非常方便的编译快捷键
;; (setq compile-command "make -j 3 cd=true d=true")
;; (defun mark-one-key-compile ()
;; "先保存文件,然后编译,不包括测试横须"
;; (interactive)
;; (save-some-buffers t)
;; (compile compile-command))

;; (global-set-key "\C-xcc" 'mark-one-key-compile)

;; (c-set-style "ellemtel")
;; (setq c-default-style "ellemtel" c-basic-offset 2)
;; (setq tab-width 2 indent-tabs-mode nil)
;; (setq indent-tabs-mode t)

;; ;; set the default spilt direction
;; ;; some bad effects!!!
;; (setq split-height-threshold nil)
;; (setq split-width-threshold 0)

;;koson

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

;;koson
;; (setq default-tab-width 4)
;; (setq-default indent-tabs-mode  t)
;; M-x eval-buffer
;; we can make the configer effective without restart emacs 
(global-set-key [f1] 'eval-buffer)

;; open shell with other window horizontally
(defun my-open-shell ()
(interactive)

 (split-window-horizontally)
 (other-window 1 )
 (shell)
)

(global-set-key [f2] 'my-open-shell)
(global-set-key [(control f5)] 'revert-buffer)

(global-set-key [(control f6)] 'c-mode)
(global-set-key [(control f7)] 'vc-diff)

;; to roll screen with out moving cursor
(global-set-key [M-down] 'View-scroll-line-forward)
(global-set-key [M-up] 'View-scroll-line-backward)

;; complie setting 
(global-set-key [f5] 'compile)
(setq-default compile-command "make")

;; align region with expression
(global-set-key [(control  ?\;)] 'align-regexp)     
;; increase/decrease the front of emacs word display
(global-set-key [(control ?+)] 'text-scale-increase)
(global-set-key [(control ?-)] 'text-scale-decrease)

(delete-selection-mode t)

;;**********************    android setting    *********************           
;; (add-to-list 'load-path' "~/.emacs.d/lisp/android")
;; (require 'android-compile)
;;  (add-hook 'c++-mode-hook 'android-compile)
;;  (add-hook 'java-mode-hook 'android-compile)
;;  (global-set-key [f9] 'android-compile)

;;**********************    basic setting    *********************

;;Load_path
(add-to-list 'load-path' "~/.emacs.d/lisp/plugins")

;;todo_path
(setq todo-file-do "~/emacs/todo/do")
(setq todo-file-done "~/emacs/todo/done")
(setq todo-file-top "~/emacs/todo/top")

;;Personal information
(setq user-full-name "wujiao")
(setq user-mail-address "wujiao159@gmail.com") 

;;======================    time setting        =====================
;;启用时间显示设置,在minibuffer上面的那个杠上(忘了叫什么来着)
(display-time-mode 1)

;;时间使用24小时制
(setq display-time-24hr-format t)

;;时间显示包括日期和具体时间
(setq display-time-day-and-date t)

;;时间栏旁边启用邮件设置
(setq display-time-use-mail-icon t)

;;时间的变化频率
(setq display-time-interval 10)

;;显示时间,格式如下
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t) 
;;----------------------    END    time setting    ---------------------


;;======================    color setting        =====================
;; 指针颜色设置为白色
(set-cursor-color "purple")
;; 鼠标颜色设置为白色
;;(set-mouse-color "white")
;; 设置背景颜色和字体颜色
;;(set-foreground-color "white")
;; (set-background-color "darkblue")
;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
;;(set-face-foreground 'highlight "white")
;; (set-face-background 'highlight "blue")

;; (set-background-color "#202020") ;; 使用黑色背景
;; (set-foreground-color "white") ;; 使用白色前景

(set-background-color "#f7f7f7") ;; 使用白色背景,就像文件浏览器的白色
(set-face-background 'region "#505050") ;; 有点儿像巧克力的颜色,选择起来不刺眼

(set-face-foreground 'region "cyan")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")

;;设置日历的一些颜色
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))

;;-------------------------Shell 使用 ansi color-------------
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;;----------------------    END    color setting    ---------------------


;;设置emacs启动窗口大小
(setq default-frame-alist 
'((height . 32) (width , 50) (menu-bar-lines . 20) (tool-bar-lines . 0))) 


;;不要生成临时文件
(setq-default make-backup-files nil)

;;设置中文语言环境
;;(set-language-environment 'Chinese-GB)

;;写文件的编码方式
;;(set-buffer-file-coding-system 'gb2312)
(set-buffer-file-coding-system 'utf-8)

;;新建文件的编码方式
;;(setq default-buffer-file-coding-system 'gb2312)
(setq default-buffer-file-coding-system 'utf-8)

;;终端方式的编码方式
(set-terminal-coding-system 'utf-8)

;;键盘输入的编码方式
;;(set-keyboard-coding-system 'gb2312) 
(set-keyboard-coding-system 'utf-8) 
    
;;读取或写入文件名的编码方式
(setq file-name-coding-system 'utf-8) 

;;打开就启用 text 模式
(setq default-major-mode 'text-mode)

;;禁用启动信息
(setq inhibit-startup-message t) 

;; 取消自动保存,不太明智
 ;; (auto-save-mode 0)

;;语法高亮
(global-font-lock-mode t) 

;;把这些缺省禁用的功能打开
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)


;;打开图片显示功能
(auto-image-file-mode t) 

;;防止页面滚动时跳动, scroll-margin 3 可以在靠近屏幕边沿
;;3行时就开始滚动,可以很好的看到上下文
(setq scroll-margin 3
       scroll-conservatively 10000)

;;关闭烦人的出错时的提示声。
(setq visible-bell t)

;;以 y/n 替代 yes/no
(fset 'yes-or-no-p 'y-or-n-p)

;;显示行列号
(column-number-mode t) 
;;显示行号
(global-linum-mode 1)
;;显示列号
(setq mouse-yank-at-point t)


;;用一个很大的 kill ring. 这样防止我不小心删掉重要的东西。
(setq kill-ring-max 200)

;;括号匹配时显示另一端的括号,而不是跳过去
(show-paren-mode t)
(setq show-paren-style 'parentheses)


;;在标题栏显示buffer的名字,而不是 emacs@wangyin.com 这样没用 的提示。
(setq frame-title-format "emacs@%b")

;;光标显示为一条竖线
(setq-default cursor-type 'bar)

;;使用C-k删除指针到改行末的所有东西
(setq-default kill-whole-line t)


;;增大函数变量查找的寻找范围
(setq apropos-do-all t)

;;使用aspell程序作为emacs的拼写检查程序
(setq-default ispell-program-name "aspell")

;;使用narrow功能的一个设置
;; (put 'narrow-to-region 'disabled nil)

;;隐藏工具栏
(tool-bar-mode nil) 
    
;;去掉菜单栏,将F10绑定为显示菜单栏,需要菜单栏了可以摁F10调出,再摁F10就去掉菜单
;; (menu-bar-mode nil)

;; 隐藏滚动条。实际上emacs-nox是没有这个模式的。
;;(scroll-bar-mode nil) 


;;光标靠近鼠标指针时,让鼠标指针自动让开
;; (mouse-avoidance-mode 'animate) 
    
;;不要在鼠标光标出插入
(setq mouse-yank-at-point t) 
    
;;高亮显示选中的区域
(transient-mark-mode t) 
    
;;支持emacs和外部程序的拷贝粘贴
(setq x-select-enable-clipboard t) 
    
;;在标题栏提示当前位置
(setq frame-title-format "Current@%b")

;;可以递归的使用 minibuffer
;; (setq enable-recursive-minibuffers t)	

;;显示80列就换行
;;(add-hook 'message-mode-hook (lambda ()
;;(setq default-fill-column 80) 
;;(turn-on-auto-fill)))


;;禁止终端响铃
(setq visiable-bell t) 
    
;;设置tab为4个空格的宽度
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

;;设置一下备份时的版本控制,这样更加安全。
(setq version-control t)
(setq kept-new-versions 3)
(setq delete-old-versions t)
(setq kept-old-versions 2)
(setq dired-kept-versions 1)

;;设置备份时的版本控制,这样更加安全。
(mapcar
  (function (lambda (setting)
                     (setq auto-mode-alist
                               (cons setting auto-mode-alist))))
   '(("\\.xml$".  sgml-mode)
     ("\\\.bash" . sh-mode)
     ("\\.rdf$".  sgml-mode)
     ("\\.session" . emacs-lisp-mode)
     ("\\.l$" . c-mode)
     ("\\.css$" . css-mode)
     ("\\.cfm$" . html-mode)
     ("gnus" . emacs-lisp-mode)
     ("\\.idl$" . idl-mode)))

;;让 dired 可以递归的拷贝和删除目录
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)

;;时间戳设置(time-stamp),设定文档上次保存的信息
;;只要里在你得文档里有Time-stamp:的设置,就会自动保存时间戳
;;启用time-stamp
(setq time-stamp-active t)

;;去掉time-stamp的警告?
(setq time-stamp-warn-inactive t)

;;设置time-stamp的格式,我如下的格式所得的一个例子:<hans 05/18/2004 12:01:12>
(setq time-stamp-format "%:u %02m/%02d/%04y %02H02M02S")

;;将修改时间戳添加到保存文件的动作里。
(add-hook 'write-file-hooks 'time-stamp)

;;在文档最后自动插入空白一行,好像某些系统配置文件是需要这样的
(setq require-final-newline t)
(setq track-eol t)

;;光标显示为一竖线
;;(setq-default cursor-type 'bar)

;;使用C-k删掉指针到改行末的所有东西
(setq-default kill-whole-line t)

;;设定删除保存记录为200,可以方便以后无限恢复
(setq kill-ring-max 200)

;;增大使用查找函数和变量的寻找范围
(setq apropos-do-all t)

;;是用aspell程序作为Emacs的拼写检查成学
(setq-default ispell-program-name "aspell")

;;使用narrow功能时的一个设置
(put 'narrow-to-region 'disabled nil)

;;启动Emacs自动设置为两个窗口(上下各一个)
;; (split-window-vertically)

;;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)


(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)
 '(cua-mode t nil (cua-base))
 '(display-time-mode t)
 '(ecb-options-version "2.40")
 '(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
 '(ecb-source-path (quote (("/home/jiaowu/work/4780/kernel" "LNX"))))
 '(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.
 )


;;koson
;; this seems no use to C mode , but useful for java
;; (setq tab-width 4)
;; (setq default-tab-width 4)
;; (setq indent-tabs-mode t)
;; (setq c-basic-offset 4)

;;koson
;; C language setting
;; let the file indent with tab, and the tab width is 4
;; (add-hook 'c-mode-hook
;;  		  '(lambda ()
;;  			 (c-set-style "K&R")
;;  			 (setq tab-width 4)
;;  			 (setq indent-tabs-mode t)
;;  			 (setq c-basic-offset 4)))
;;  
;; ;; C++ language setting
;; (add-hook 'c++-mode-hook
;;  		  '(lambda ()
;;  			 (c-set-style "K&R")
;;  			 ;;(c-toggle-auto-state)
;;  			 (setq tab-width 4)
;;  			 (setq indent-tabs-mode t)
;;  			 (setq c-basic-offset 4)))
;;  
;; ;; text mode setting
;; (add-hook 'text-mode-hook 
;;  		  '(lambda ()
;;  			 (setq tab-width 4)
;;  			 (setq indent-tabs-mode t)
;;  			 (setq indent-line-function 'insert-tab)
;;  			))


;; cflow setting
(add-to-list 'load-path
			      "/usr/local/share/emacs/site-lisp/") 
(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)
  )


;;高亮
(load-file "~/.emacs.d/elpa/highlight-symbol/highlight-symbol.el")
(require 'highlight-symbol)
(global-set-key [(control f8)] 'highlight-symbol)
(global-set-key [f8] 'highlight-symbol-next)
(global-set-key [(shift f8)] 'highlight-symbol-prev)
(global-set-key [(meta f8)] 'highlight-symbol-query-replace)


;;cscope
(load-file "/usr/share/emacs/site-lisp/xcscope/xcscope.el")
(require 'xcscope)

 类似资料: