emacs配置

;;显示行号
;; 如果想所有打开的文件都显示行的话就打开下面的注释
(add-to-list 'load-path "D:/software/Emacs/site-lisp")
;;(setq global-display-line-number-mode t)

;; 加载显示行号模块
(require 'display-line-number)

;; 设置显示格式
(setq display-line-number-format "%4d|")

;; 在 tool bar 上增加一个图标,
;; 注意: 一定要在 load-path 中 可以找到 display-line-nuber.xpm 文件才行。
;;
(tool-bar-add-item "display-line-number"
                   'display-line-number-mode
                   'display-line-number-mode
                   :help "display line number!"
                   :button (cons :toggle  '(and (boundp
                                                 display-line-number-mode)
                                                display-line-number-mode)))

;; 使用方法
;; M-x display-line-number-mode
;; 用来 toggle 显示行号的模式
;; M-x display-line-number-mode-on
;; 启动显示行号的模式
;; M-x display-line-number-mode-off
;; 关闭显示行号的模式
;; 仅对某种 mode 启动显示行号的模式
;; (add-hook 'c-mode-hook 'display-line-number-mode)
;;显示行号结束

;;为什么使用语法显示的大文件在移动时如此之慢
(setq lazy-lock-defer-on-scrolling t)
;;(setq font-lock-support-mode 'lazy-lock-mode)
(setq font-lock-maximum-decoration t)

 

(add-to-list 'load-path "D:/software/Emacs/site-lisp/ecb-2.32")
(require 'xcscope) ;;加载xcscope
(require 'cedet) ;;加载cedet

(require 'ecb) ;;加载ecb
(require 'session) ;;加载session
(add-hook 'after-init-hook 'session-initialize) ;; 启动时初始化session
(require 'doxymacs) ;; 启动doxymacs

(global-set-key [f12] 'ecb-activate) ;;定义F12键为激活ecb
;;(global-set-key [C-f12] 'ecb-deactivate) ;;定义Ctrl+F12为停止ecb


;;设置你的全名和邮件
(setq user-full-name "Weng wuzi")
(setq user-mail-address "wengjingfu2@126.com")

 


;;设置自动缩进
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())

;;set c program style
(add-hook 'c-mode-hook 'linux-c-mode)
(setq imenu-sort-function 'imenu--sort-by-name)
(defun linux-c-mode()
 (define-key c-mode-map [return] 'newline-and-indent)
 (interactive)
 (c-set-style "K&R")
 (c-toggle-auto-state)
 (c-toggle-hungry-state)
 (setq c-basic-offset 4)
 (imenu-add-menubar-index)
 (which-function-mode)
)


;;设置你的书签文件,默认是~/.emacs.bmk,我喜欢把有关emacs的文件尽量放在一个文件夹,所以就修改了。
(setq bookmark-default-file "~/.emacs.d/.emacs.bmk")
;;设置缩略词的文件?不大记得了
(setq abbrev-file-name "~/.emacs.d/.abbrev_defs")

;;设置打开的默认路径
(setq default-directory "D:/cygwin/usr/pro")

 


;;设置info的路径,也可通过Shell的全局变量$INFOPATH设置
(add-to-list 'Info-default-directory-list "~/local/info/")
;; 指针颜色设置为白色
(set-cursor-color "white")
;; 鼠标颜色设置为白色
(set-mouse-color "white")
;; 光标颜色设置
(set-cursor-color "green")
;; 设置背景颜色和字体颜色
(set-foreground-color "cyan")
(set-background-color "black")
;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
;;(set-face-foreground 'highlight "white")
;;(set-face-background 'highlight "NavyBlue")
;;(set-face-foreground 'region "cyan")
;;(set-face-background 'region "blue")
;;(set-face-foreground 'secondary-selection "skyblue")
;;(set-face-background 'secondary-selection "darkblue")
(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.
 '(font-lock-builtin-face ((t (:foreground "magenta"))))
 '(font-lock-comment-face ((t (:foreground "LawnGreen"))))
 '(font-lock-constant-face ((t (:foreground "Orange"))))
 '(font-lock-doc-string-face ((t (:foreground "Red"))) t)
 '(font-lock-function-name-face ((t (:foreground "SlateBlue1"))))
 '(font-lock-keyword-face ((t (:foreground "OrangeRed"))))
 '(font-lock-other-type-face ((t (:foreground "BlueViolet"))) t)
 '(font-lock-string-face ((t (:foreground "gold"))))
 '(font-lock-type-face ((t (:foreground "DeepPink1"))))
 '(font-lock-variable-name-face ((t (:foreground "grey100"))))
 '(font-lock-warning-face ((t (:foreground "turquoise1")))))
 

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

;;外观设置
;;去掉工具栏
(tool-bar-mode nil)
;;去掉菜单栏,我将F10绑定为显示菜单栏,万一什么东西忘了,需要菜单栏了可以摁F10调出,再摁F10就去掉菜单
(menu-bar-mode nil)
;;不要滚动栏,现在都用滚轴鼠标了,可以不用滚动栏了
(scroll-bar-mode nil)

;;备份设置
;;emacs还有一个自动保存功能,默认在~/.emacs.d/auto-save-list里,这个非常有用,我这里没有改动,具体可以参见Sams teach yourself emacs in 24hours(我简称为sams24)
;;启用版本控制,即可以备份多次
(setq version-control t)
;;备份最原始的版本两次,记第一次编辑前的文档,和第二次编辑前的文档
(setq kept-old-versions 2)
;;备份最新的版本五次,理解同上
(setq kept-new-versions 5)
;;删掉不属于以上7中版本的版本
(setq delete-old-versions t)
;;设置备份文件的路径
(setq backup-directory-alist '(("." . "~/.emacs.tmp")))
;;备份设置方法,直接拷贝
(setq backup-by-copying t)

;;特别有意思的是 try-expand-line,它可以帮你补全整整一行文字。我很多时后有两行文字大致相同,只有几个字不一样,但是我懒得去拷贝粘贴以下。那么我就输入这行文字的前面几个字。然后多按几下 M-/ 就能得到那一行。
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
'(try-expand-line
try-expand-line-all-buffers
try-expand-list
try-expand-list-all-buffers
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name
try-complete-file-name-partially
try-complete-lisp-symbol
try-complete-lisp-symbol-partially
try-expand-whole-kill))


;;时间显示设置
;;启用时间显示设置,在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)

;;启用minibuffer,好像是默认设置吧
(minibuffer-electric-default-mode 1)
;;启用部分补全功能,如输入M-x q r r相当于M-x query-replace-regexp
(partial-completion-mode 1)
;;在minibuffer里启用自动补全函数和变量
(icomplete-mode 1)
;;所有的问题用y/n方式,不用yes/no方式。有点懒,只想输入一个字母
(fset 'yes-or-no-p 'y-or-n-p)
;;允许minibuffer自由变化其大小(指宽度)
(setq resize-mini-windows t)
;;当寻找一个同名的文件,自动关联上那个文件?
(setq uniquify-buffer-name-style 'forward)
;;在emacs读man文档时,使用当前buffer
(setq Man-notify-method 'pushy)
;;鼠标自动避开指针,如当你输入的时候,指针到了鼠标的位置,鼠标有点挡住视线了
(mouse-avoidance-mode 'animate)
;;允许自动打开图片,如wiki里面
(auto-image-file-mode)
;;可以操作压缩文档
(auto-compression-mode 1)
;;在minibuffer上面可以显示列号
(column-number-mode t)
;;显示默认的文档的宽度,看起来比较舒服?
(setq default-fill-column 60)
;;指针不要闪,我得眼睛花了
(blink-cursor-mode -1)
(transient-mark-mode 1)
;;当指针到一个括号时,自动显示所匹配的另一个括号
(show-paren-mode 1)
;;是用滚轴鼠标
(mouse-wheel-mode t)
;;去掉烦人的警告铃声
(setq visible-bell nil)
;;滚动页面时比较舒服,不要整页的滚动
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)

;;设定句子结尾,主要是针对中文设置
(setq sentence-end "//([。!?]//|……//|[.?!][]/"')}]*//($//|[ /t]//)//)[ /t/n]*")
(setq sentence-end-double-space nil)
;;去掉Emacs和gnus启动时的引导界面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;;当指针移到另一行,不要新增这一行?
(setq next-line-add-newlines nil)
;;在文档最后自动插入空白一行,好像某些系统配置文件是需要这样的
(setq require-final-newline t)
(setq track-eol t)
;;使用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标题栏的标题
(setq frame-title-format "%b@vj.org")
;;允许emacs和外部其他程序的粘贴
(setq x-select-enable-clipboard t)

;;日志功能设置
(setq calendar-latitude +26.1)
(setq calendar-longitude +119.3)
;;我的配置文件里很多东西忘了,欢迎大家来指正下
(setq calendar-remove-frame-by-deleting t)
;;设定一周的开始为周一
(setq calendar-week-start-day 1)
;;节日和生日提醒设置
;;我不过基督徒的节日、希伯来人的节日和伊斯兰教的节日。
;;我是无神论者,不过我喜欢神话,大家有兴趣也可以探讨一下,发email给我吧
(setq christian-holidays nil)
(setq hebrew-holidays nil)
(setq islamic-holidays nil)
;;设定一些自定义的生日和节日
;;隐私需要,删掉朋友的生日
;;后面那些农历节日需要每年根据日历修改
;;有些可惜,没有中国传统农历,谁能写个扩展elisp包弄一下
(setq general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 3 8 "妇女节")
(holiday-fixed 4 1 "愚人节")
(holiday-fixed 4 11 "谁的生日")
(holiday-fixed 5 1 "劳动节")
(holiday-fixed 10 1 "国庆节")
(holiday-fixed 12 25 "圣诞节")
(holiday-fixed 2 5 "元宵节")
(holiday-fixed 4 4 "清明节")
(holiday-fixed 4 21 "鬼节")
(holiday-fixed 6 22 "端午节")
(holiday-fixed 9 28 "中秋节")
(holiday-float 5 0 2 "母亲节")
(holiday-float 6 0 3 "父亲节")
))
;;其他的一些设置
;;日历不和日记相连,我不用Calendar自带的diary记日记
(setq mark-diary-entries-in-calendar nil)
;;这个又忘了,我真是忘性好!
(setq appt-issue-message nil)
;;在日历中突出标记节日和生日
(setq mark-holidays-in-calendar t)
;;打开calendar自动打开节日和生日列表
(setq view-calendar-holidays-initially t)
;;下面两个是设置年份为中国年,好像默认的是用英文写的,由王垠修改的。
;;这个设置在节日列表的春节那天能看到,如今年的春节他就写着
;;Thursday, January 22, 2004: Chinese New Year (甲-申)
(setq chinese-calendar-celestial-stem
["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])

;;统一设置键帮定,并尽量放在配置文件的最后,以免被绑定的键不小心被后面的配置文件覆盖
;;常用习惯,F1打开帮助,常用帮助有info和woman(就是在emacs中看man)
(global-set-key [f1] 'info)
;;恢复,常用键
(global-set-key [f2] 'undo)
;;反恢复,不是很常用,但是绑定了还是方便些
(global-set-key [f3] 'redo)
;;F4,kill键,习惯设置,关闭当前buffer
(global-set-key [f4] 'kill-this-buffer)
;;打开一个终端,根据你的爱好可以绑定为:eshell,shell,terminal-emulator
(global-set-key [f5] 'term)
;;文件管理器,常用
(global-set-key [f6] 'dired-jump)
;;同clear相识,具体功能在hvj-functions.el讲过
(global-set-key [f7] 'hvj-line-to-top-of-window)
;;本人正在学scheme,常用
(global-set-key [f8] 'run-scheme)
;;看新闻组,常用的很,不过更多时间现在sir里
(global-set-key [f9] 'gnus)
;;习惯设置,打开/关闭菜单
(global-set-key [f10] 'menu-bar-mode)
;;编译等,暂时还不常用
(global-set-key [f11] 'compile)

;;习惯设置,Home键设定光标到文件开头
(global-set-key [(home)] 'beginning-of-buffer)
;;习惯设置,End键设定光标到文件结尾
(global-set-key [(end)] 'end-of-buffer)

;;meta在常用PC键上就是Alt键
;;这三个绑定主要是光标移动的
(global-set-key [(meta down)] 'goto-line)
(global-set-key [(meta left)] 'backward-sexp)
(global-set-key [(meta right)] 'forward-sexp)

;;用Emacs时常用多个窗口,窗口之间的移动很常见
;;默认的绑定感觉不对劲,换了
(global-set-key [(control o)] 'other-window)
;;这就是我的切换buffer的设置,同windows操作相识
;;没法,windows用了两年多,有些习惯还真不好改
;;不过emacs的配置就是好配,随你配
(global-set-key [(control tab)] 'tabbar-forward)
;;这个设置是改变outline的快捷键前缀
;;outline主要用于编程等,目前用的不多
(setq outline-minor-mode-prefix [(control o)])

;;默认的Ctrl-z是什么来着,关闭emacs吧,好像还是强行关闭,不好,用C-x c就好了
;;我就将Ctrl-z作为我的键的绑定
(define-prefix-command 'ctl-z-map)
(global-set-key (kbd "C-z") 'ctl-z-map)
;;编译当前emacs-lisp源码为elc
(global-set-key (kbd "C-z b") 'emacs-lisp-byte-compile)
;;打开我得日历
(global-set-key (kbd "C-z c") 'calendar)
;;字典功能,就是查单词
(global-set-key (kbd "C-z d d") 'dictionary-lookup-definition)
;;与上面类似
(global-set-key (kbd "C-z d s") 'dictionary-search)
;;查询当前单词的匹配的单词,用于补全单词
(global-set-key (kbd "C-z d m") 'dictionary-match-words)
;;字典提示模式,同字典的自动取词功能相似
(global-set-key (kbd "C-z d t") 'dictionary-tooltip-mode)
;;启动我的IRC客户端,到sir去
(global-set-key (kbd "C-z e s") 'erc-irc)
;;到fans聊天去
(global-set-key (kbd "C-z e f") 'erc-fans)
;;启动拼写检查模式,只检查打开后输入的单词
(global-set-key (kbd "C-z f m") 'flyspell-mode)
;;对整个buffer进行拼写检查
(global-set-key (kbd "C-z f b") 'flyspell-buffer)
;;打开gnus
(global-set-key (kbd "C-z g") 'gnus)
;;数数本文件有多少文字
(global-set-key (kbd "C-z h c") 'hvj-count-words-region)
;;同Clear键
(global-set-key (kbd "C-z h l") 'hvj-line-to-top-of-window)
;;拼写检查
(global-set-key (kbd "C-z i") 'ispell-minor-mode)
;;debug
(global-set-key (kbd "C-z j") 'jdb)
;;查看前面删除的内容记录
(global-set-key (kbd "C-z k") 'browse-kill-ring)
;;打印当前buffer
(global-set-key (kbd "C-z l") 'lpr-buffer)
;;启动我得maxima,漂亮模式
(global-set-key (kbd "C-z m") 'imaxima)
;;绑定两个narrow功能
(global-set-key (kbd "C-z n n") 'narrow-to-region)
(global-set-key (kbd "C-z n w") 'widen)
(global-set-key (kbd "C-z o") 'occur)
;;几个小游戏
(global-set-key (kbd "C-z p g") 'gomoku)
(global-set-key (kbd "C-z p t") 'tetris)
;;由于在html-helper-mode模式中F4键失效,用这个绑定来关闭buffer
(global-set-key (kbd "C-z q") 'kill-this-buffer)
;;带正则表达式的搜索
(global-set-key (kbd "C-z r") 'query-replace-regexp)
;;我得scheme也是可以在emacs中运行的
(global-set-key (kbd "C-z s") 'run-scheme)
;;我的终端
(global-set-key (kbd "C-z t") 'term)
;;可以在emacs编辑文件使用vim习惯,常用的是vi-mode和viper-mode
(global-set-key (kbd "C-z v") 'vi-mode)
;;我的文件管理器
(global-set-key (kbd "C-z u d") 'dired-jump)
(global-set-key (kbd "C-z u f") 'folding-mode)
(global-set-key (kbd "C-z u o") 'outline-minor-mode)
;;查询service,见hvj-other-elisp
(global-set-key (kbd "C-z u s") 'services-look-up)
;;wiki中的绑定设置,还用的不多
(global-set-key (kbd "C-z w c") 'emacs-wiki-change-project)
(global-set-key (kbd "C-z w f") 'emacs-wiki-find-file)
(global-set-key (kbd "C-z w h") 'emacs-wiki-preview-html)
(global-set-key (kbd "C-z w i") 'emacs-wiki-index)
(global-set-key (kbd "C-z w p") 'emacs-wiki-publish)
(global-set-key (kbd "C-z w s") 'emacs-wiki-search)
;;我的浏览器
(global-set-key (kbd "C-z w w") 'w3m)
;;同C-z b有点不同,在编译后并加载
(global-set-key (kbd "C-z x") 'emacs-lisp-byte-compile-and-load)
;;同yank有点不一样,但具体怎样忘了,感觉这个比yank好点
(global-set-key (kbd "C-z y") 'clipboard-yank)
;;修改后的设定mark的绑定,由于经常忘了放住control键,就给这个功能两个绑定了
(global-set-key (kbd "C-z z") 'set-mark-command)
(global-set-key (kbd "C-z C-z") 'set-mark-command)

;;there are severl other key-map below in other files
;;ctrl-f-folding-mode-prefix
;;ido key-map
;;severl self define functions related key-bindings.

 

(global-set-key [f10] 'menu-bar-mode)

 

(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.
 '(blink-cursor-mode nil nil (frame))
 '(column-number-mode t)
 '(cua-mode nil)
 '(ecb-gzip-setup (quote cons))
 '(ecb-options-version "2.32")
 '(ecb-tar-setup (quote cons))
 '(ecb-wget-setup (quote cons))
 '(global-font-lock-mode t nil (font-core))
 '(menu-bar-mode t nil (menu-bar))
 '(show-paren-mode t nil (paren))
 '(transient-mark-mode t))


(put 'upcase-region 'disabled nil)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值