emacs配置2

来源:互联网 发布:n86软件 编辑:程序博客网 时间:2024/05/29 01:54
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Filename:     .emacs
;;                
;; Version:       2.0
;; Author:        <2008@126.com>
;; Created at:    Sat Mar  1 16:40:04 2014
;;                
;; Description:   emacs配置总结
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; 添加Emacs搜索路径
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/plugins")
;;设定语言环境为utf-8  
(setq current-language-environment "UTF-8")  
(setq locale-coding-system 'utf-8) 
(set-terminal-coding-system 'utf-8)  
(set-keyboard-coding-system 'utf-8)  
(set-selection-coding-system 'utf-8)  
(prefer-coding-system 'utf-8)  
(setq default-sendmail-coding-system 'utf-8-unix);发送邮件编码

;; 从color-theme中获取
;; M-x color-theme-select,鼠标左键选中,回车查看效果
(require 'color-theme)
(setq color-theme-is-global t)
(color-theme-dark-blue2)
;; 使用tabbar.el
(require 'tabbar)
(tabbar-mode)
;;(global-set-key (kbd "C-2") 'tabbar-backward)
;;(global-set-key (kbd "C-1") 'tabbar-forward)
;;设置字体
(set-default-font "-unknown-DejaVu Sans Mono-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1")

;;(require 'ibus)
;;(add-hook 'after-init-hook 'ibus-mode-on)
;;(global-set-key (kbd "C-M-\\") 'ibus-toggle) ;;通过Ctrl+Mata+\切换输入法
;; 显示时间,格式如下
(display-time-mode 1)  
(setq display-time-24hr-format t)  
(setq display-time-day-and-date t)  

;;Personal information
(setq user-full-name "Lxxxx")
(setq user-mail-address "xxxxx2008@126.com")

;; 以 y/n代表 yes/no
(fset 'yes-or-no-p 'y-or-n-p)

;;显示标题栏 %f 缓冲区完整路径 %p 页面百分数 %l 行号
(setq frame-title-format "xxxx@%f")

;;缺省模式 text-mode
(setq default-major-mode 'text-mode)

;;设置默认工作目录
(setq default-directory "/home/ubuntu/workfile")

;; 默认显示 80列就换行
(setq default-fill-column 80)

;; 去掉工具栏
(tool-bar-mode nil)

;;去掉菜单栏
;;(menu-bar-mode nil)

;; 去掉滚动栏
(scroll-bar-mode nil)

;; 显示列号
(setq column-number-mode t)
(setq line-number-mode t)

;;高亮显示选中的区域
(transient-mark-mode t)
;;高亮显示成对括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;;时间栏旁边启用邮件设置
(setq display-time-use-mail-icon t)

;;鼠标指针避光标
(mouse-avoidance-mode 'animate)
;;粘贴于光标处,而不是鼠标指针处
(setq mouse-yank-at-point t)
;; 指针颜色设置为白色
(set-cursor-color "white")
;; 鼠标颜色设置为白色
(set-mouse-color "white")

;;禁用启动信息
(setq inhibit-startup-message t)

;;不要生成临时文件
(setq-default make-backup-files nil)
                                        ;关闭自动保存模式
(setq auto-save-mode nil)
                                        ;不生成 #filename# 临时文件
(setq auto-save-default nil)

;;打开图片显示功能
(auto-image-file-mode t)

;;设定行距
(setq default-line-spaceing 4)

;;设置删除记录
(setq kill-ring-max 200)

;;以空行结束
(setq require-final-newline t)

;;页面平滑滚动,scroll-margin 3 靠近屏幕边沿3行开始滚动,正好可以看到上下文
(setq scroll-margin 3 scroll-consrvatively 10000)

;;禁止终端响铃
(setq visiable-bell t)

;; 支持emacs和外部程序的粘贴
(setq x-select-enable-clipboard t)

;;语法高亮
(global-font-lock-mode t)
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)

;;可以递归的使用 minibuffer
(setq enable-recursive-minibuffers t)

;;让 dired 可以递归的拷贝和删除目录
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)

;; 设置缩进
(setq c-basic-offset 4)
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
      (setq tab-stop-list (cons (* x 4) tab-stop-list)))

;; 回车缩进
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key (kbd "C-<return>") 'newline)


;; 最大化
(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
  )
;; 启动emacs时窗口最大化
(my-maximized)

;; 启动窗口大小
;;(setq default-frame-alist
;;      '((height . 35) (width . 125) (menu-bar-lines . 20) (tool-bar-lines . 0)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(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)
 '(display-time-mode t)
 '(ecb-options-version "2.40")
 '(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
 '(ecb-source-path (quote ("/home/ubuntu/workfile")))
 '(line-number-mode nil)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(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 "#233b5a" :foreground "#fff8dc" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 111 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;代码折叠
(load-library "hideshow")
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'perl-mode-hook 'hs-minor-mode)
(add-hook 'php-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;;代码折叠
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'c++-mode-hook 'hs-minor-mode)  
;;Group Buffer设置
;;自动进入Topic-mode
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

;;Sumarry Buffer设置
(setq gnus-summary-line-format ":%U%R %B %s %-60=|%4L |%-20,20f |%&user-date; \n")

;;Article Buffer设置
;;设定要显示的头消息格式
(setq gnus-visible-headers
      "^\\(^To:\\|^CC:\\|^From:\\|^Subject:\\|^Date:\\|^Followup-To:
\\|^X-Newsreader:\\|^User-Agent:\\|^X-Mailer:
\\|Line:\\|Lines:\\|Content-Type:\\|NNTP-Posting-Host\\)")

;; 使用 C++ mode
;;(add-to-list 'auto-mode-alist (cons "\\.h$" #'c++-mode))
;;可以设置对于不同的文件绑定不同的模式,可以用以下语句实现:
;;set *.h and *.c and *.cpp files use c++ mode
(setq auto-mode-alist
      (cons '("\\.h$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist
      (cons '("\\.c$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist
      (cons '("\\.cpp$" . c++-mode) auto-mode-alist))

;; CC-mode配置
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;;;我的C/C++语言编辑策略

;;热键设置
;; 按下Alt+/,就会弹出菜单让你自动补全
(define-key c-mode-base-map [(tab)] 'semantic-ia-complete-symbol-menu)

;;(global-set-key [f5] 'complile)
;;(setq-default compile-command "make")

;;(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 [(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)
;;_____________C______________
;;C预处理设置                                                            
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "c")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq abbrev-mode t)
;;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;;___________CPP______________
;;CPP预处理设置
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq abbrev-mode t)
;;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)


;;热键设置
;;
;;define-key global-map "\M-pi" 'cscope-set-initial-directory)    
;;define-key global-map "\M-pi" 'cscope-unset-initial-directory)  
;;define-key global-map "\M-pi" 'cscope-find-this-symbol)  
;;define-key global-map "\M-pi" 'cscope-find-global-definition)    
;;define-key global-map [(control f7)] 'cscope-find-global-definition-no-prompting)    
;;define-key global-map [(control f8)] 'cscope-pop-mark)  
;;define-key global-map [(control f9)] 'cscope-next-symbol)    
;;define-key global-map [(control f10)] 'cscope-next-file)    
;;define-key global-map [(control f11)] 'cscope-prev-symbol)  
;;define-key global-map [(control f12)] 'cscope-prev-file)    
;;define-key global-map [(meta f9)] 'cscope-display-buffer)    
;;define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)    
;;
;;

;;文本界面下禁用此代码折叠  
;;(when (and window-system (require 'semantic-tag-folding nil 'noerror))  
;;  (global-semantic-tag-folding-mode 1)  
;;  (global-set-key (kbd "C-?") 'global-semantic-tag-folding-mode)  
;;  (define-key semantic-tag-folding-mode-map (kbd "C-c , -") 'semantic-tag-folding-fold-block)  
;;  (define-key semantic-tag-folding-mode-map (kbd "C-c , +") 'semantic-tag-folding-show-block)  
;;  (define-key semantic-tag-folding-mode-map (kbd "C-_") 'semantic-tag-folding-fold-all)  
;;  (define-key semantic-tag-folding-mode-map (kbd "C-+") 'semantic-tag-folding-show-all))  
;;

(global-set-key [f1] 'undo)
(global-set-key [f2] 'goto-line) ;条装到某一行
(global-set-key [f3] 'comment-or-uncomment-region) ; 注释 / 取消注释
;;格式化整个文件函数
(defun indent-whole ()
  (interactive)
  (indent-region (point-min) (point-max))
  (message "format successfully"))
;;绑定到F4键
(global-set-key [f4] 'indent-whole)
(setq compile-command "make -f Makefile") ;编译
(setq-default compile-command "make")
(global-set-key [f5] 'complile)
;;启动窗口gdb
(global-set-key [f6] 'gdb)
;;(global-set-key [f7] 'gdb-many-windows)
(global-set-key [f8] 'semantic-ia-fast-jump)    ; 智能跳转 跳转到定义  
(global-set-key [M-S-f8] 'semantic-analyze-proto-impl-toggle) ;在函数的声明和实现之间来回跳转  
(global-set-key [M-f8] 'eassist-switch-h-cpp) ;头文件和源文件之间跳转的快捷键

(global-set-key [f9] 'tabbar-forward)  
(global-set-key [f10] 'tabbar-backward)
(global-set-key [f11] 'kill-this-buffer)
;; 实现全屏效果,快捷键为f12
(global-set-key [f12] 'my-fullscreen)
(defun my-fullscreen ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_FULLSCREEN" 0))
  )

(global-set-key (kbd "C-1") 'shell)
(global-set-key (kbd "C-2") 'hs-hide-block) ; 折叠  
(global-set-key (kbd "C-3") 'hs-show-block) ; 展开  

;;关闭当前窗口
(global-set-key (kbd "M-4") 'delete-window)
;;关闭其他窗口
(global-set-key (kbd "M-1") 'delete-other-windows)
;;水平分割窗口
(global-set-key (kbd "M-2") 'split-window-vertically)
;;垂直分割窗口
(global-set-key (kbd "M-3") 'split-window-horizontally)
;;切换其他窗口
(global-set-key (kbd "M-0") 'other-window)
;;创建其他frame
(global-set-key (kbd "M-5") 'make-frame-command)
;;切换道另一个frame
(global-set-key (kbd "M-6") 'other-frame)
;;关闭frame
(global-set-key (kbd "M-7") 'make-frame-invisible)


;;======================            自动补全功能        =====================
;;自动补全功能,这事从王垠的网站直接Copy过来的,引用一些他对此的说明
;;设置以下 hippie-expand 的补全方式。它是一个优先列表, hippie-expand 会优先使用表最前面
;;的函数来补全这是说,首先使用当前的buffer补全,如果找不到,就到别的可见的窗口里寻找,如
;;还找不到,那么到所有打开的buffer去找,如果还……那么到kill-ring里,到文件名,到简称列表
;;里,到list,当前使用的匹配方式会在 echo 区域显示。
;;特别有意思的是 try-expand-line,它可以帮你补全整整一行文字。我很多时后有两行文字大致相
;;同,只有几个字不一样,但是我懒得去拷贝粘贴以下。那么我就输入这行文字的前面几个字。然后
;;多按几下 M-/ 就能得到那一行。
(global-set-key [(meta ?/)] 'hippie-expand)    ;使用hippie-expand补全(M+/快捷键)
(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))

;;hippie的自动补齐策略,优先调用了senator
(autoload 'senator-try-expand-semantic "senator")
;;配置Semantic的检索范围
(setq semanticdb-project-roots
      (list
       (expand-file-name "/")))
;;自定义自动补齐命令,这部分是抄hhuu的,如果在单词中间就补齐,否则就是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)    ;使用(c+tab)补全
;;=======================================================================
;;====================== 拷贝代码自动格式化 =====================
;;Emacs 里对代码的格式化支持的非常好,不但可以在编辑的时候自动帮你格式化,还可以选中一块代码,
;;按 Ctrl-Alt-\ 对这块代码重新进行格式化.如果要粘贴一块代码的话,粘贴完了紧接着按 Ctrl-Alt-\,
;;就可以把新加入的代码格式化好。可是,对于这种粘贴加上重新格式化的机械操作,Emacs 应该可以将
;;它自动化才能配得上它的名气,把下面的代码加到配置文件里,你的 Emacs 就会拥有这种能力了
(dolist (command '(yank yank-pop))
  (eval
   `(defadvice ,command (after indent-region activate)
      (and (not current-prefix-arg)
           (member major-mode
                   '(                     c-mode
                                          c++-mode
                                          clojure-mode
                                          emacs-lisp-mode
                                          haskell-mode
                                          js-mode
                                          latex-mode
                                          lisp-mode
                                          objc-mode
                                          perl-mode
                                          cperl-mode
                                          plain-tex-mode
                                          python-mode
                                          rspec-mode
                                          ruby-mode
                                          java-mode
                                          scheme-mode))
           (let ((mark-even-if-inactive transient-mark-mode))
             (indent-region (region-beginning) (region-end) nil))))))
;;=======================================================================

;;===================== 文件头header设置结束
(require 'auto-header) ;加载auto-header.el文件,自动添加文件头
;; 设置文件头中的姓名
(setq header-full-name "LaiJia")
;; 设置邮箱
(setq header-email-address "laijia2008@126.com")

;; 设置每次保存时要更新的项目
(setq header-update-on-save
      '(  filename
          modified
          counter
          copyright))
;; 设置文件头的显示格式
(setq header-field-list
      '(  filename  ;文件名
          blank    ;空行,下同
          ;;copyright ;;版权
          version
          author  ;作者
          created   ;创建人
          blank
          description   ;描述
          ;;blank
          ;;modified_by ;更改者
          ;; blank
          ;;status  ;状态,是否发布
          ;;更新
          ;;blank
          ))
;;添加文件头:C-x C-h m
;;添加函数头:C-x C-h f
;;===========================================================================

;;调用linum.el(line number)来显示行号:
(require 'linum)
(global-linum-mode 1)
;;===========================================================================
;;Auto complete

(add-to-list 'load-path "~/.emacs.d/plugins/auto-complete-1.3.1")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/plugins/auto-complete-1.3.1/ac-dict")
(ac-config-default)
(setq ac-use-quick-help nil)
(setq ac-auto-start 2) ;; 输入2个字符才开始补全
(global-set-key "\M-\\" 'auto-complete)  ;; 补全的快捷键,用于需要提前补全(M+\)
;; Show menu 0.8 second later
(setq ac-auto-show-menu 0.2)
;; 选择菜单项的快捷键
(setq ac-use-menu-map t)
(define-key ac-menu-map "\C-n" 'ac-next)
(define-key ac-menu-map "\C-p" 'ac-previous)
;; menu设置为12 lines
(setq ac-menu-height 12)
;;==========================================================================
;;安装clang
(require 'auto-complete-clang)
(setq ac-clang-auto-save t)  
(setq ac-auto-start t)  
(setq ac-quick-help-delay 0.5)  
;; (ac-set-trigger-key "TAB")  
;; (define-key ac-mode-map  [(control tab)] 'auto-complete)  
(define-key ac-mode-map  [(control tab)] 'auto-complete)  
(defun my-ac-config ()  
  (setq ac-clang-flags  
        (mapcar(lambda (item)(concat "-I" item))  
               (split-string  
                "
 /usr/include/c++/4.7
 /usr/include/i386-linux-gnu/c++/4.7/.
 /usr/include/c++/4.7/backward
 /usr/lib/gcc/i686-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/i686-linux-gnu/4.7/include-fixed
 /usr/include/i386-linux-gnu
 /usr/include
")))  
  (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))  
  (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)  
  ;; (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)  
  (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)  
  (add-hook 'css-mode-hook 'ac-css-mode-setup)  
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)  
  (global-auto-complete-mode t))  
(defun my-ac-cc-mode-setup ()  
  (setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))  
(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)  
;; ac-source-gtags  
(my-ac-config)  
;;需要说明的几点是:
;;ac-clang-flags是头文件的目录,根据系统的不同可能你的头文件目录也会不同,列出系统中所有的头文件目录方法是:
;;$ echo "" | g++ -v -x c++ -E -
;;==========================================================================
;;yasnippet
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet)
(setq yas/prompt-functions
      '(yas/dropdown-prompt yas/x-prompt yas/completing-prompt yas/ido-prompt yas/no-prompt))
(yas/global-mode 1)
(yas/minor-mode-on) ; 以minor mode打开,这样才能配合主mode使用
;;=========================================================================

;;========================================================================
;;配置cedet环境

(add-to-list 'load-path "~/.emacs.d/cedet-1.1/common")
(add-to-list 'load-path "~/.emacs.d/cedet-1.1/eieio")
(add-to-list 'load-path "~/.emacs.d/cedet-1.1/semantic")
(require 'cedet)
(require 'semantic-ia)
(require 'semantic-gcc)
(require 'semanticdb-global)
(semanticdb-enable-gnu-global-databases 'c-mode)
(semanticdb-enable-gnu-global-databases 'c++-mode)
;;(semantic-load-enable-primary-exuberent-ctags-support)
;;;实现代码折叠
(require 'semantic-tag-folding nil 'noerror)  
(global-semantic-tag-folding-mode 1)
;; 整个buffer所有函数折叠与展开  
(define-key semantic-tag-folding-mode-map [(control f3)] 'semantic-tag-folding-fold-all)  
(define-key semantic-tag-folding-mode-map [(control f4)] 'semantic-tag-folding-show-all)
(define-key semantic-tag-folding-mode-map [(control f5)] 'semantic-tag-folding-fold-block)  
(define-key semantic-tag-folding-mode-map [(control f6)] 'semantic-tag-folding-show-block)
;;(define-key global-map [(control f1)] 'ecb-hide-ecb-windows)
;;(global-ede-mode 1)
;; Enable SRecode (Template management) minor-mode.
;;(global-srecode-minor-mode 1)
;;(semantic-load-enable-minimum-features)
;;(semantic-load-enable-code-helpers)
;;(semantic-load-enable-semantic-debugging-helpers)
;;补全
;;(define-key c-mode-base-map (kbd "M-n") 'semantic-ia-complete-symbol-menu)
;;(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;==========================================================================
;;ecb
(add-to-list 'load-path "~/.emacs.d/ecb-2.40/")
(require 'ecb)
(setq ecb-auto-activate t
      ecb-tip-of-the-day nil)
(setq ecb-tip-of-the-day nil)
(setq ecb-help-info-start-file nil)   ;(require 'ecb-autoloads)
(setq inhibit-startup-message t)
(setq ecb-auto-compatibility-check nil)
(setq ecb-version-check nil)
;;第一次使用时先要设置项目目录,M-x customize-variable ecb-source-path ,在这里加上你的项目根目录。接下来使用M-x ecb-active就能激活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 [(control f1)] 'ecb-hide-ecb-windows)
(define-key global-map [(control f2)] 'ecb-show-ecb-windows)


;;;; 使某一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)
;; Ecb的操作:
;; C-c . g d 目录列表窗口
;; C-c . g s 源码窗口
;; C-c . g m 方法和变量窗口
;; C-c . g h 历史窗口
;; C-c . g l 最后选择过的编辑窗口
;; C-c . g 1 编辑窗口1
;; C-c . g n 编辑窗口n
;; C-c . l c 选择版面
;; C-c . l r 重画版面
;; C-c . l t 拴牢版面(锁定版面)
;; C-c . l w 拴牢可见的ecb窗口
;; C-c . \ 拴牢编绎窗口
;;=========================================================================
;;cscopxe 设置
;;使用 cscope 浏览源代码,这个xcscope是个改进版,为每一次查找的结果使用不同 buffer ,
;;这样就可以保存以前的结果。

(add-to-list 'load-path "~/.emacs.d/xcscope") ;;将软件包所在的路径加到 EMACS 的 load-path
(require 'xcscope) ;; 加载相应的软件
(setq cscope-do-not-update-database t)
(define-key global-map "\C-css" 'cscope-find-this-symbol)
(define-key global-map "\C-csd" 'cscope-find-global-definition)
(define-key global-map "\C-csg" 'cscope-find-global-definition)
(define-key global-map "\C-csG" 'cscope-find-global-definition-no-prompting)
(define-key global-map "\C-csc" 'cscope-find-functions-calling-this-function)
(define-key global-map "\C-csC" 'cscope-find-called-functions)
(define-key global-map "\C-cst" 'cscope-find-this-text-string)
(define-key global-map "\C-cse" 'cscope-find-egrep-pattern)
(define-key global-map "\C-csf" 'cscope-find-this-file)
(define-key global-map "\C-csi" 'cscope-find-files-including-file)
;; --- (The '---' indicates that this line corresponds to a menu separator.)
(define-key global-map "\C-csb" 'cscope-display-buffer)
(define-key global-map "\C-csB" 'cscope-display-buffer-toggle)
(define-key global-map "\C-csn" 'cscope-next-symbol)
(define-key global-map "\C-csN" 'cscope-next-file)
(define-key global-map "\C-csp" 'cscope-prev-symbol)
(define-key global-map "\C-csP" 'cscope-prev-file)
(define-key global-map "\C-csu" 'cscope-pop-mark)
;; ---
(define-key global-map "\C-csa" 'cscope-set-initial-directory)
(define-key global-map "\C-csA" 'cscope-unset-initial-directory)
;; ---
(define-key global-map "\C-csL" 'cscope-create-list-of-files-to-index)
(define-key global-map "\C-csI" 'cscope-index-files)
(define-key global-map "\C-csE" 'cscope-edit-list-of-files-to-index)
(define-key global-map "\C-csW" 'cscope-tell-user-about-directory)
(define-key global-map "\C-csS" 'cscope-tell-user-about-directory)
(define-key global-map "\C-csT" 'cscope-tell-user-about-directory)
(define-key global-map "\C-csD" 'cscope-dired-directory)
;; The previous line corresponds to be end of the "Cscope" menu.
;;cscope -Rbkq建立索引文件
;; C-c s a 设定初始化的目录,一般是你代码的根目录
;; C-c s I 对目录中的相关文件建立列表并进行索引
;; C-c s s 序找符号
;; C-c s g 寻找全局的定义
;; C-c s c 看看指定函数被哪些函数所调用
;; C-c s C 看看指定函数调用了哪些函数
;; C-c s e 寻找正则表达式
;; C-c s f 寻找文件
;; C-c s i 看看指定的文件被哪些文件include
;;==========================================================================
;;配置flymake 进行语法检查
;;(autoload 'flymake-find-file-hook "flymake" "" t)
;;(add-hook 'find-file-hook 'flymake-find-file-hook)
;;(setq flymake-gui-warnings-enabled nil) ;;flymake-gui-warnings-enabled设置为nil表示出错时不弹个对话框显示错误
;;(setq flymake-log-level 0);;flymake-log-level设置为0表示记录错误日志。
;;说明:带的flymake对C/C++的支持是通过Makefile实现的,Makefile中必须有一个check-syntax目标,
;;;比如我在Linux下用automake,那我在Makefile.am中加了这么一段(其实就是调用gcc):
;;check-syntax:
;;$(CXXCOMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
;;==========================================================================
;;gnus设置
;;M-x gnus 启动gnus模式  常用 M-x gnus-other-frame 来新开一个emacs处理
;; (setq gnus-select-method '(nntp "news.cn99.com")) ;;其他 news.somewhere.cn服务器设置
;; (setq gnus-secondary-select-methods '((nnml "")))
;; (setq user-full-name "LaiJia")
;; (setq user-mail-address "laijia2008@126.com")
;;  
;; (setq mail-interactive "t")
;; ;;set pop server
;; (setq mail-sources
;;        '((pop :server "pop.163.com"        ;; 在这里设置 pop3 服务器
;;               :user "laijia2008@126.com"   ;; 用户名
;;               :port 110
;;               :password "15122840452")))   ;; 密码
;;  
;; (setq pop3-leave-mail-on-server t)
;; ;; set smtp
;; (setq smtpmail-auth-credentials
;;        '(("smtp.163.com"               ;; SMTP 服务器
;;           25                           ;; 端口号
;;           "laijia2008@126.com"         ;; 用户名
;;           "15122840452")))             ;; 密码
;;  
;; (setq smtpmail-default-smtp-server "smtp.163.com")
;; (setq smtpmail-smtp-server "smtp.163.com")
;; (setq message-send-mail-function 'smtpmail-send-it)
;;M-x mail 发送邮件, C-c C-s 发送,C-c C-c 发送并退出
;;M-x rmail 接受邮件
;;===========================================================================
;;Emacs配置python开发环境
;;===========================================================================
;;Emacs配置git环境
(add-to-list 'load-path "~/.emacs.d/git-emacs/")
(require 'git-emacs)
;;基本操作
;;如果当前打开的文件所在的文件夹处于版本控制中,可以通过M-x git-status查看状态
;;在这个界面下可以使用一些命令:
;;p/n         在所有文件之间上下移动
;;P/N         在变更过的文件之间上下移动
;;</>         定位到列表的头部/尾部
;;v         以只读方式打开文件
;;m/u/SPC         设置/取消/切换标记,标记用于批量处理文件
;;a         将文件加入版本控制
;;i         将文件加入ignore
;;c         提交
;;在状态清单中使用“c",或者在任何buffer中运行M-x git-commit/git-commit-all/git-commit-file,可以提交index/所有文件/当前文件
;;C-c C-c    提交
;;C-c C-q    取消
;;命令 M-x git-history可以查看整个工程的版本历史,M-x git-log可以查看当前标记文件的版本历史
;;M-x git-branch:列出所有分支,在这里可以通过快捷键c/d/RET实现创建/删除/切换分支
;;M-x git-tag可以创建一个标签,以后在git-checkout时可以指定标签的名字,也可以通过git-checkout-to-new-branch来基于tag创建分支
;;===========================================================================
;;http://www.cnblogs.com/zfreay/archive/2012/01/08/2316441.html emacs 配置java开发环境
(add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/")
(add-to-list 'load-path "~/.emacs.d/elib-1.0/")
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
;; 不自动加载jde-mode
(setq defer-loading-jde t)
;; 编辑.java文件时加载jde
(if defer-loading-jde
    (progn
      (autoload 'jde-mode "jde" "JDE mode." t)
      (setq auto-mode-alist
            (append
             '(("\\.java\\'" . jde-mode))
             auto-mode-alist)))
  (require 'jde))
(setq jde-check-version-flag nil)
(setq jde-web-browser "netscape")
(setq jde-db-set-source-paths "/opt/Java/jdk1.7.0_51/src/;/home/ubunut/java/")
;;(jde-db-set-source-paths "C:/Java/jdk1.6.0_22/src/;D:/data1/java/")
(define-obsolete-function-alias 'make-local-hook 'ignore "21.1")
(unless (fboundp 'semantic-format-prototype-tag-java-mode)
  (defalias 'semantic-format-prototype-tag-java-mode 'semantic-format-tag-prototype-java-mode))
;; to read:
;;(setq defer-loading-jde t)
;;
;;说明:在Emacs中舒服地写Java程序了……C-c C-v C-c编译并检查错误,C-c C-v C-r运行程序!
;;####################################################################
;;;(load "jde")
;;(setq jde-doc-dir "C:/Java/jdk1.6.0_22/docs/")
;;
;;;;(setq shell-file-name "bash")
;;;;(setq shell-command-switch "-c")
;;
;;;; prj.el
;;
;;;; Class path setting
;;(setenv "CLASSPATH" ".;C:/Java/jdk1.6.0_22/src/;D:/data1/javaclass/;C:/Java/jdk1.6.0_22/lib/")
;;;; Compile options
;;(jde-set-compile-options "-d \"D:/data1/java\" -debug")
;;;; Application's main class
;;(jde-run-set-app "foo.main")
;;;; Source paths
;;(jde-db-set-source-paths "C:/Java/jdk1.6.0_22/src/;D:/data1/java/")

0 0
原创粉丝点击