skuldjf 2010-01-30
Ubuntu 9.10下Emacs配置文件
;;------------------颜色主题---------------------------
(setq load-path (cons "~/.emacs.d" load-path))
(require 'color-theme)
(color-theme-initialize)
(color-theme-dark-blue)
;;----------------------以下是我的快捷键设置---------------------
;; ----------------------- Short Cut -------------------------
(global-set-key [(meta g)] 'goto-line)
;;(global-set-key [(meta ?/)] 'hippie-expand)
;; F12 t 从当前缓冲区建立任务
(global-set-key (kbd "<f12> t") 'planner-create-task-from-buffer)
;; F12 g 切换到当日的任务
;;(global-set-key (kbd "<f12> g") 'planner-goto-today)
(global-set-key (kbd "<f12> g") 'planner-goto-today)
(global-set-key (kbd "<f12> p") 'plan)
;; F12 r 添加当前备忘录
(global-set-key (kbd "<f12> r") 'remember)
;; F12 c 切换到日历
(global-set-key (kbd "<f12> c") 'calendar)
;;;F2:进入wiki-mode模式
(global-set-key [(f2)] 'emacs-wiki-find-file)
;;;F3:切换到dired模式
(global-set-key [(f3)] 'dired)
;;;F4:切换到shell模式
(global-set-key [(f4)] 'ansi-term)
;;;F5:打开speedbar
(global-set-key [(f5)] 'speedbar)
;;;;F7:调用compile
(global-set-key (kbd "<f7>") 'compile)
;;;Alt+s : 让speedbar获得焦点
(global-set-key (kbd "M-s") 'speedbar-get-focus)
;;;F9:列举我的书签
(global-set-key (kbd "<f9>") 'list-bookmarks)
;;;F10:添加当前页到书签中
(global-set-key [(f10)] 'bookmark-set)
;;;F12 u 更新当前版本
(global-set-key (kbd "<f12> u") 'vc-next-action)
;;------------------------End of Short Cut ---------------------
;;-------------------------关闭启动时的`开机画面'------------
(setq inhibit-startup-message t)
;;-------------------------显示列号--------------------------
;;(setq column-number-mode t)
;;display the column number and line number
(setq column-number-mode t)
(setq line-number-mode t)
(global-linum-mode t)
;;-------------------------使用Win下的选择习惯---------------
;;用shift+方向键进行选择
(pc-selection-mode)
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq default-fill-column 80);默认显示 80列就换行
;;-------------------------设置默认Tab宽度---------------
;;set default tab-width as 4, not 2
(setq-default indent-tabs-mode nil)
(setq default-tab-width 8)
;;;; 显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;;;;设置大的kill ring
(setq kill-ring-max 150)
;;;;导入CEDET的各个插件
;; ---------------------------------------
;; Load CEDET
(load-file "~/.emacs.d/cedet-1.0pre6/common/cedet.el")
;; Enabling various SEMANTIC minor modes. See semantic/INSTALL for more ideas.
;; Select one of the following
(semantic-load-enable-code-helpers)
;; (semantic-load-enable-guady-code-helpers)
;; (semantic-load-enable-excessive-code-helpers)
;; Enable this if you develop in semantic, or develop grammars
;; (semantic-load-enable-semantic-debugging-helpers)
;; ---------------------------------------
;;;; 配置 Emacs Code Browser
(add-to-list 'load-path
"~/.emacs.d/ecb-2.40")
(require 'ecb)
;;;;配置Sementic的检索范围
(setq semanticdb-project-roots
(list
(expand-file-name "/")))
;;;; CC-mode配置 http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;;;根据后缀判断所用的mode
;;;;注意:我在这里把.h关联到了c++-mode
(setq auto-mode-alist
(append '(("\\.h$" . c++-mode)) auto-mode-alist))
;;;;我的C/C++语言编辑策略
(defun my-c-mode-common-hook()
(setq tab-width 4 indent-tabs-mode nil)
;;; hungry-delete and auto-newline
(c-toggle-auto-hungry-state 1)
;;按键定义
(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 [(f7)] 'compile)
(define-key c-mode-base-map [(f8)] 'ff-get-other-file)
(define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;预处理设置
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq hs-minor-mode t)
(setq abbrev-mode t)
(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "Stroustrup")))
;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
(c-set-style "stroustrup")
;; (define-key c++-mode-map [f3] 'replace-regexp)
)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
;;;;C/C++语言启动时自动加载semantic对/usr/include的索引数据库
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
(lambda ()
(setq semanticdb-project-system-databases
(list (semanticdb-create-database
semanticdb-new-database-class
"/usr/include")))))
;;;;我的Java语言编辑策略
(defun my-java-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'java-mode-hook 'my-java-mode-hook)
;;;;光标靠近鼠标指针时让鼠标指针自己闪开
(mouse-avoidance-mode 'animate)
;;;;修改标题栏,显示buffer的名字
(setq frame-title-format "%b")
;;;;启动Emacs Server
;;(server-start)
;;;;每次进入Emacs即显式Plan
;;;;(plan)(color-theme-dark-blue)
;;;;高亮当前行
(require 'hl-line)
(global-hl-line-mode t)
;;;;向左右滚动的命令激活:C-x < 和 C-x >
(put 'scroll-left 'disabled nil)
;;配置一下shell的颜色
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(setq ansi-color-for-comint-mode t)
;;;;退出Emacs时保存所有正在编辑的文档
;;(load "desktop")
;;(desktop-save-mode)
;;(desktop-read)