我的.emacs配置

在Ubuntu上用emacs 23开发C++已经有一段时间了,基本上主要使用emacs 23,eclipse配合。emacs 23主要用于写代码,debug,编译;eclipse主要用于整个项目替换、复制等等。到目前为止,还不错。

 

下面是我的emacs 23的配置:

 

;; Nomral setting
(setq default-major-mode 'text-mode)
(global-font-lock-mode t)
(auto-image-file-mode t)
(transient-mark-mode t)
(show-paren-mode t)
(column-number-mode t)
(tool-bar-mode nil)
(setq-default make-backup-files nil)
(mouse-avoidance-mode 'animate)
(setq x-select-enable-clipboard t)

;; autorevert stuff
(autoload 'auto-revert-mode "autorevert" nil t)
(autoload 'turn-on-auto-revert-mode "autorevert" nil nil)
(autoload 'global-auto-revert-mode "autorevert" nil t)
(global-auto-revert-mode 1)

;; Load linum
(add-to-list 'load-path "/home/goo/site-lisp")
(require 'linum)
(global-linum-mode t)

;; Load session
(require 'session)
(add-hook 'after-init-hook 'session-initialize)

;; load color-theme
(add-to-list 'load-path "/home/goo/site-lisp/color-theme")
(require 'color-theme)
(eval-after-load "color-theme"
  '(progn
     (color-theme-initialize)
     (color-theme-hober)))

;; XML setting
(add-to-list 'load-path "/home/goo/site-lisp/nxml-mode")
(load "/home/goo/site-lisp/nxml-mode/rng-auto.el")
(add-hook 'nxml-mode-hook (lambda()
                (setq tab-width 2)
                (setq indent-tabs-mode t)))
(setq auto-mode-alist (cons '("//.//(xml//|xsl//|xsd//)//'" . nxml-mode) auto-mode-alist))

;; Load xcscope
(add-to-list 'load-path "/home/goo/site-lisp/xcscope")
(require 'xcscope)

;; Load cedet
(add-to-list 'load-path "/home/goo/site-lisp/cedet/common")
(require 'cedet)
(semantic-load-enable-code-helpers)
;(semantic-load-enable-guady-code-helpers)
;(semantic-load-enable-excessive-code-helpers)
(global-set-key [(f5)] 'speedbar)

(setq semanticdb-project-roots
      (list
       (expand-file-name "/")
       )
)

(defun my-indent-or-complete ()
  (interactive)
  (if (looking-at "//>")
      (hippie-expand nil)
    (indent-for-tab-command)
    )
)

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

;; C/C++ setting
(require 'cc-mode)
(setq c-basic-offset 4)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)

(defun my-c-mode-common-hook()
  (setq tab-width 4)
  (setq indent-tabs-mode t)
  (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))
  (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
  (define-key c-mode-base-map [(ctrl tab)] 'semantic-ia-complete-symbol-menu)
  (define-key c-mode-base-map [(f9)] 'compile)
  (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)
  (c-set-style "user")
  (hl-line-mode t)
)

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c++-mode-common-hook 'my-c-mode-common-hook)

(setq auto-mode-alist (cons '("//.h$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("//.cpp$" . c++-mode) auto-mode-alist))

;; Load ecb
(add-to-list 'load-path "/home/goo/site-lisp/ecb")
(require 'ecb)
(global-set-key [f12] 'ecb-activate)
(global-set-key [C-f12] 'ecb-deactivate)


(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)
 '(ecb-layout-window-sizes nil)
 '(ecb-options-version "2.40")
 '(ecb-tip-of-the-day nil)
 '(show-paren-mode t))
(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.
 '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 106 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值