2009年5月6日星期三

emacs配置

参考:http://www.caole.net/diary/emacs_setting.html
color-theme配置
#apt-get install emacs-goodies-el
(require 'color-theme)
;;(color-theme-initialize)
;;(color-theme-tty-dark)
;;(color-theme-comidia)
;;(color-theme-dark-laptop)
;;(color-theme-sitaramv-solaris)

(set-face-background 'default "#334455")
(set-face-foreground 'default "wheat")
(set-cursor-color "white")



;; 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.
'(browse-url-mozilla-program "firefox")
'(case-fold-search-t nil)
'(column-number-mode t)
'(compilation-scroll-output t)
'(compile-command "make")
'(current-language-environment "Chinese-GB")
'(display-time-mode t)
'(ecb-options-version "2.32")
'(global-font-lock-mode t)
'(show-paren-mode t)
'(tab-width 4)
'(tool-bar-mode nil)
'(transient-mark-mode t)




;;;; 显示行号:
(setq column-number-mode t)
(setq line-number-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)


;;;;自动补齐策略

(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
)
)




;;;; 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)

;;;;我的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)
)

(setq visible-bell 't) ;用闪屏代替振铃

(show-paren-mode 't) ;括号配对显示

没有评论:

发表评论