上次配好的emacs,不幸因为系统崩溃全没了。这次乖了点,我发到网上。
;;;;;;;;;;;;;;;;;;;;;乱八糟的设置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 设置背景颜色和字体颜色
(add-to-list 'load-path "~/.emacs.d/")
(require 'color-theme)
(color-theme-initialize)
(color-theme-dark-blue)
;;------------语言环境字符集设置(utf-8)-------------
(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-selection-coding-system 'utf-8)
(modify-coding-system-alist 'process "*" 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8))
(setq-default pathname-coding-system 'utf-8)
(set-file-name-coding-system 'utf-8)
(setq ansi-color-for-comint-mode t)
;;启动设置
(setq default-frame-alist
'((vertical-scroll-bars)
(top . 25)
(left . 45)
(width . 40)
(height . 40)
(foreground-color . "grey")
(cursor-color . "gold1")
(mouse-color . "gold1")
(tool-bar-lines . 0)
(menu-bar-lines . 1)
(right-fringe)
(left-fringe)))
(setq initial-frame-alist '((top . 0) (left . 0) (width . 142) (height . 49)))
;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")
;;------------显示时间设置------------------------------
(display-time-mode 1);;启用时间显示设置,在minibuffer上面的那个杠上
(setq display-time-24hr-format t);;时间使用24小时制
(setq display-time-day-and-date t);;时间显示包括日期和具体时间
(setq display-time-use-mail-icon t);;时间栏旁边启用邮件设置
(setq display-time-interval 10);;时间的变化频率,单位多少来着?
;;设置打开文件的缺省路径
(setq default-directory "~/")
(setq visible-bell t)
;;关闭烦人的出错时的提示声
;;取消工具栏
(tool-bar-mode nil)
;;外观设置
;;去掉Emacs和gnus启动时的引导界面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;;;; 显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;;;; 关闭启动画面
(setq inhibit-startup-message t)
;;;;设置大的kill ring
(setq kill-ring-max 150)
(setq default-fill-column 120)
;;把 fill-column 设为 60. 这样的文字更好读
(setq-default indent-tabs-mode nil)
(setq default-tab-width 8);;tab键为8个字符宽度
(setq tab-stop-list ())
;;不用 TAB 字符来indent, 这会引起很多奇怪的错误。编辑 Makefile 的时候也不用担心,因为 makefile-mode 会把 TAB 键设置成真正的 TAB 字符,并且加亮显示的。
(setq sentence-end "//([。!?]//|……//|[.?!][]/"')}]*//($//|[ /t]//)//)[ /t/n]*")
(setq sentence-end-double-space nil)
;;设置 sentence-end 可以识别中文标点。不用在 fill 时在句号后插入两个空格。
(setq enable-recursive-minibuffers t)
;;可以递归的使用 minibuffer
(setq scroll-margin 3 scroll-conservatively 10000)
;;防止页面滚动时跳动, scroll-margin 3 可以在靠近屏幕边沿3行时就开始滚动,可以很好的看到上下文。
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;设置缺省主模式是text,,并进入auto-fill次模式.而不是基本模式fundamental-mode
(show-paren-mode t)
;;打开括号匹配显示模式
(setq show-paren-style 'parenthesis)
;;括号匹配时可以高亮显示另外一边的括号,但光标不会烦人的跳到另一个括号处。
(mouse-avoidance-mode 'animate)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。
(setq show-paren-mode t) ;;打开括号匹配显示模式
(setq show-paren-style 'parenthesis)
;;括号匹配时可以高亮显示另外一边的括号,但光标不会烦人的跳到另一个括号处。
(setq frame-title-format "emacs@%b")
;;在标题栏显示buffer的名字,而不是 emacs@wangyin.com 这样没用的提示。
(setq global-font-lock-mode t)
;;进行语法加亮。
(column-number-mode t)
(defun du-onekey-compile ()
"Save buffers and start compile"
(interactive)
(save-some-buffers t)
(switch-to-buffer-other-window "*compilation*")
(compile compile-command))
(global-set-key [C-f5] 'compile)
(global-set-key [f5] 'du-onekey-compile)
;; C-f5, 设置编译命令; f5, 保存所有文件然后编译当前窗口文件
(global-set-key [f6] 'gdb)
;;F6设置为在Emacs中调用gdb
(fset 'yes-or-no-p 'y-or-n-p)
;; 改变 Emacs 固执的要你回答 yes 的行为。按 y 或空格键表示 yes,n 表示 no。
;; 语法高亮。除 shell-mode 和 text-mode 之外的模式中使用语法高亮。
(setq font-lock-maximum-decoration t)
(setq font-lock-global-modes '(not shell-mode text-mode))
(setq font-lock-verbose t)
(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;;不要在鼠标点击的那个地方插入剪贴板内容。我不喜欢那样,经常把我的文档搞的一团糟。我觉得先用光标定位,然后鼠标中键点击要好的多。不管你的光标在文档的那个位置,或是在 minibuffer,鼠标中键一点击,X selection 的内容就被插入到那个位置。
(setq mouse-yank-at-point t)
;;设置日历的一些颜色
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))
;;允许emacs和外部其他程序的粘贴
(setq x-select-enable-clipboard t)
(setq mouse-yank-at-point t)
(setq user-full-name "Chenzhi")
(setq user-mail-address "*****@163.com")
;;设置有用的个人信息,这在很多地方有用。
(setq Man-notify-method 'pushy)
;; 当浏览 man page 时,直接跳转到 man buffer。
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
;;设置home键指向buffer开头,end键指向buffer结尾
(global-set-key [f6] 'gdb)
;;F6设置为在Emacs中调用gdb
(global-set-key [C-f7] 'previous-error)
(global-set-key [f7] 'next-error)
(defun open-eshell-other-buffer ()
"Open eshell in other buffer"
(interactive)
(split-window-vertically)
(eshell))
(global-set-key [(f8)] 'open-eshell-other-buffer)
(global-set-key [C-f8] 'eshell)
;;目的是开一个shell的小buffer,用于更方便地测试程序(也就是运行程序了),我经常会用到。
;;f8就是另开一个buffer然后打开shell,C-f8则是在当前的buffer打开shell
(setq speedbar-show-unknown-files t);;可以显示所有目录以及文件
(setq dframe-update-speed nil);;不自动刷新,手动 g 刷新
(setq speedbar-update-flag nil)
(setq speedbar-use-images nil);;不使用 image 的方式
(setq speedbar-verbosity-level 0)
(global-set-key [f9] 'speedbar)
;;设置f9调用speedbar命令
;;使用 n 和 p 可以上下移动,
;; + 展开目录或文件进行浏览,- 收缩,RET 访问目录或文件,g 更新 speedbar。
(global-set-key [f11] 'calendar)
;;设置F11快捷键指定Emacs 的日历系统
(global-set-key [f12] 'list-bookmarks)
;;设置F12 快速察看日程安排
;;----------日历设置--------------------
;;设置日历的一些颜色
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))
(global-set-key [f3] 'repeat-complex-command)
(global-set-key [f4] 'other-window)
;; 跳转到 Emacs 的另一个buffer窗口
(defun du-onekey-compile ()
"Save buffers and start compile"
(interactive)
(save-some-buffers t)
(switch-to-buffer-other-window "*compilation*")
(compile compile-command))
(global-set-key [C-f5] 'compile)
(global-set-key [f5] 'du-onekey-compile)
(global-set-key [f1] 'manual-entry)
(global-set-key [C-f1] 'info )
(global-set-key [f2] 'emacs-wiki-find-file)
;;打开wiki
;;中文相关
;;(set-language-environment 'Chinese-GB)
;;(setq gnus-default-charset 'chinese-iso-8bit
;;gnus-group-name-charset-group-alist '((".*" . chinese-iso-8bit))
;;gnus-summary-show-article-charset-alist
;;'((1 . chinese-iso-8bit)
;;(2 . gbk)
;;(3 . big5)
;;(4 . utf-8))
;;gnus-newsgroup-ignored-charsets
;;'(unknown-8bit x-unknown iso-8859-1))
;;;; 显示行号:
(setq column-number-mode t)
(setq line-number-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; cedet
(load-file "/usr/share/emacs/site-lisp/cedet-common/cedet.el")
;; 设置检索范围
(setq semanticdb-project-roots
(list
(expand-file-name "/")));;可以设置为项目的顶级目录
;; 绑定按键,ctr+tab,以下三种,任意选择一个,我喜欢第二个
;;(global-set-key [(control tab)] 'senator-complete-symbol);
(global-set-key [(control tab)] ' senator-completion-menu-popup)
;; (global-set-key [(control tab)] 'semantic-ia-complete-symbol-menu)
(semantic-load-enable-excessive-code-helpers)
;;;使数体能够折叠或展开
(global-semantic-tag-folding-mode 1)
;; Key bindings
(defun my-cedet-hook ()
(local-set-key [(control return)] 'semantic-ia-complete-symbol)
(local-set-key "/C-c?" 'semantic-ia-complete-symbol-menu)
(local-set-key "/C-cd" 'semantic-ia-fast-jump)
(local-set-key "/C-cr" 'semantic-symref-symbol)
(local-set-key "/C-cR" 'semantic-symref))
(add-hook 'c-mode-common-hook 'my-cedet-hook)
;;;;自动补齐策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "//>")
(hippie-expand nil)
(indent-for-tab-command))
)
(global-set-key [(control tab)] 'my-indent-or-complete)
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-semantic
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-expand-list
try-expand-list-all-buffers
try-expand-line
try-expand-line-all-buffers
try-complete-file-name-partially
try-complete-file-name
try-expand-whole-kill
)
)
;;;; 当输入"."或">"时,在另一个窗口中列出结构体或类的成员
(defun my-c-mode-cedet-hook ()
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert))
(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;ecb的设置
(add-to-list 'load-path "/usr/share/emacs/site-lisp/ecb")
(require 'ecb)
;;;; 自动启动ecb,并且不显示每日提示
(setq ecb-auto-activate t
ecb-tip-of-the-day nil)
inhibit-startup-message t;不知道什么意思,望各位指导
ecb-auto-compatibility-check nil;
ecb-version-check nil;
)
(global-set-key [f8] 'ecb-activate) ;;定义F8键为激活ecb
(global-set-key [f7] 'ecb-deactivate) ;;定义F7为停止ecb
;;;; 各窗口间切换
(global-set-key [M-left] 'windmove-left)
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down] 'windmove-down)
;;;; 使某一ecb窗口最大化
(define-key global-map "/C-c1" 'ecb-maximize-window-directories)
(define-key global-map "/C-c2" 'ecb-maximize-window-sources)
(define-key global-map "/C-c3" 'ecb-maximize-window-methods)
(define-key global-map "/C-c4" 'ecb-maximize-window-history)
;;;; 恢复原始窗口布局
(define-key global-map "/C-c`" 'ecb-restore-default-window-sizes)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;乱八糟的设置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; 显示行号:
(setq column-number-mode t)
(setq line-number-mode t)
;;可以打开图片
(global-font-lock-mode t)
;;;; 显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;;;; 关闭启动画面
(setq inhibit-startup-message t)
;;;;设置大的kill ring
(setq kill-ring-max 150)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C语言设定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;设置C语言编译命令
;;(set 'compile-command' "gcc -g ")
;;CC-mode配置 http://cc-mode.sourceforge.net/
(require 'cc-mode)
(require 'xcscope)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
(add-hook 'c-mode-common-hook(lambda()(c-set-style "k&r")))
;;缩进策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "//>")
(hippie-expand nil)
(indent-for-tab-command)))
;;C语言编辑策略
(defun my-c-mode-common-hook()
(setq default-tab-width 4 indent-tabs-mode nil)
(setq tab-width 4 indent-tabs-mode nil)
(setq c-basic-offset 4)
;;; hungry-delete and auto-newline
(c-toggle-auto-hungry-state 1))
;; 配置Semantic的检索范围:
(setq semanticdb-project-roots
(list
(expand-file-name "/")))
;; 自定义自动补齐命令,如果在单词中间就补齐,否则就是tab。
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "//>")
(hippie-expand nil)
(indent-for-tab-command))
)
(global-set-key [(control tab)] 'my-indent-or-complete)
;; 补全优先级
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-sematic
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;;按键定义
(define-key c-mode-base-map [(f5)] 'compile)
(global-set-key [(f6)] 'gdb)
(global-set-key [(f7)] 'gdb-many-windows)
(define-key c-mode-base-map [(control /`)] 'hs-toggle-hiding)
(define-key c-mode-base-map [(return)] 'newline-and-indent)
(define-key c-mode-base-map [(meta /`)] 'c-indent-command)
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;(define-key c-mode-base-map [(meta ?/)] 'hippie-expand)
;;多窗口gdb
;;(setq gdb-many-windows t)
;;(load-library "multi-gud.el")
;;(load-library "multi-gdb-ui.el")