;; .emacs
(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.
'(diff-switches "-u")
'(ecb-layout-window-sizes nil)
'(ecb-options-version "2.40")
'(speedbar-verbosity-level 3))
;;; uncomment for CJK utf-8 support for non-Asian users
;; (require 'un-define)
;show the offending lines or the stacktrace you would get upon adding (setq debug-on-error t) at the beginning of your .emacs.
;; 调示lisp,可以打印调用栈 信息
; (setq debug-on-error t)
;;ibuffer ;; 用 C-x C-b 切换不同 buffer 实在是太麻烦了,用 ibuffer 轻松实现 buffer 切换
(require 'ibuffer)
(global-set-key [(f4)] 'ibuffer) ;;把 ibuffer 绑定到 f4 上,轻松切换!
;;显示行号
(require 'linum)
(global-linum-mode t)
;显示列号
(column-number-mode t)
;;语法高亮
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
;;成对显示括号,但不来回弹跳
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;;重新绑定C-z到撤销
(global-set-key (kbd "C-z") 'undo)
;; 各窗口间切换 ;;(windmove-default-keybindings)
(global-set-key [C-left] 'windmove-left)
(global-set-key [C-right] 'windmove-right)
(global-set-key [C-up] 'windmove-up)
(global-set-key [C-down] 'windmove-down)
;; share clipboard with outside programs
(setq x-select-enable-clipboard t)
;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
(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")
(set-foreground-color "grey")
(set-background-color "black")
(set-cursor-color "gold1")
(set-mouse-color "gold1")
;;(set-scroll-bar-mode nil)
;设定光标为短线
(setq-default cursor-type 'bar)
;设置标题
;(setq frame-title-format
; '(" dp - Emacs - [ " (buffer-file-name "%f \]"
; (dired-directory dired-directory "%b \]"))))
;;设置标题栏显示文件的完整路径名 My set not work, why?????
;(setq frame-title-format
; '("%S" (buffer-file-name "%f"
; (dired-directory dired-directory "%b")
; )
; )
;)
;; global configuration; gtags
(load "/usr/share/emacs/site-lisp/gtags.el")
(autoload 'gtags-mode "gtags" "" t) ;gtags-mode is true
(global-set-key (kbd "M-.") 'gtags-find-tag) ;; find-tag 可以找到当前光标住函数或者字符串的定义; ESC .(英文句号) :
(global-set-key (kbd "M-,") 'gtags-find-rtag) ;; Find tag (reference); ESC ,(英文逗号)
(global-set-key (kbd "M-g M-f") 'gtags-find-file)
(global-set-key (kbd "M-g M-s") 'gtags-find-symbol)
(global-set-key (kbd "M-g M-u") 'gtags-update)
;如果要emacs自动读取 某个TAGS文件,可以在~/.emacs文件中加入一行,设置tags-file-name变量
;(setq tags-file-name "path/TAGS")
;如果要一次查找多个TAGS文件,可以设置tags-table-list变量
;(setq tags-table-list '("path1/TAGS" "path2/TAGS" "path3/TAGS"))
;另外,对于较大又不是 经常使用的TAGS,尽量放到该list的后面,避免不必要的打开
;M-* 回到上一次运行M-.前的光标位置。
;C-u M-. 查找下一个tag的位置 ??? why not act
;(setq gtags-select-tag-other-window 1) ;; 设置在不同的窗口打开选中的文件 ??? why not act
;; cscope
(require 'xcscope "/usr/share/emacs/site-lisp/xcscope.el")
(setq cscope-do-not-update-database t) ;;不用每次都更新索引文件, 可用加快检索速度;
(setq cscope-mouse-select-entry-other-window t) ;; 设置在不同的窗口打开选中的文件
;; 阅读代码 代码symbol 等的查找;
; 最简单的是etags,最复杂的是ecb(emacs code browser),位于中间的是cscope
; cscope是我感觉比较合适的一个工具。它其实是一个独立的软件,完全可以脱离vi和emacs使用。
; 但是结合emacs的强大功能,cscope就显得更加方便了。GNU Emacs默认自带cscope的支持。
; 在使用之前,cscope也需要对代码进行索引。在emacs中可以这样做:
; C-c s a 设定初始化的目录,一般是你代码的根目录
; C-s s I 对目录中的相关文件建立列表并进行索引
; 建完索引之后,你就可以用cscope在代码里游荡了。常用的一些命令如下:
;; 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
;;;; CC-mode配置 http://cc-mode.sourceforge.net/
;; the following config come from http://www.caole.net/diary/emacs_write_cpp.html
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;;;我的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 [(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) ;自动补全
; 这是semantic的相关自动补齐的命令,它会根据分析结果弹出补齐的菜单,
(define-key c-mode-base-map [(control tab)] 'semantic-ia-complete-symbol-menu) ;自动补全
;Ctrl+tab <Ctrl> + <Tab>,也有设成<Meta> + / 的,根据个人习惯
;(define-key c-mode-base-map [(tab)] 'hippie-expand) Senator 的相关自动补齐
; hippie-expand 是 Emacs 的一个非常方便的东西,用于补全输入,舒服极了。
;它通过一个函数列表来提供多重补全方式,这个变量是 hippie-expand-try-functions-list
;(global-set-key [(meta ?/)] 'hippie-expand)
;; 自动跳转
;(global-set-key [f12] 'semantic-ia-fast-jump) ; 智能跳转 跳转到定义 这个功能如此常用,我就把它绑定到f12上去了。
;(global-set-key "\C-cp" 'semantic-ia-fast-jump) ; 智能跳转 跳转到定义 这个功能如此常用,
;(global-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) ;在函数的声明和实现之间来回跳转
;(global-set-key "\C-ct" 'eassist-switch-h-cpp) ;头文件和源文件之间跳转的快捷键; .cedet-contrib里有个eassist.el,可以很方便地在c++的h/cpp文件间切换,
;;预处理设置
(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++语言编辑策略
(c-set-style "stroustrup")
;;(define-key c++-mode-map [f3] 'replace-regexp)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;; ==========================Start Load sr-speedbar========================
;;; (require 'sr-speedbar) 显示: M-x sr-speedbar-open 你可以绑定快捷建。 sr-speedbar 比speedbar好用
;;M-x sr-speedbar-refresh-turn-off 关闭自动刷新功能,可以看到稳定的列表,good
(require 'sr-speedbar "/usr/share/emacs/site-lisp/sr-speedbar.el")
(global-set-key [(f5)] 'sr-speedbar-open)
;; CEDET中还有一个不错的工具是speedbar,你可以用它在多个文件中快速切换。在我的.emacs配置文件里,我把speedbar关联到了F5上:
; 不过说实话,我自己很少用到speedbar,我通常都是用dired配合bookmark使用:)
;;(global-set-key [(f5)] 'speedbar)
;;(setq imenu-auto-scan t)
;;Speed Bar; Speed Bar在emacs23中是一个标准组件, 类似vi中的taglist,可以设置Speedbar 的更新速度,显示方式和排序分组方式:
;;(require 'semantic-sb nil t)
;;(setq speedbar-update-speed 3)
;;(setq speedbar-use-images t)
;;(setq (speedbar-tag-hierarchy-method
;; (quote (speedbar-trim-words-tag-hierarchy
;; speedbar-simple-group-tag-hierarchy
;; speedbar-sort-tag-hierarchy))))
;; ==========================Start Load sr-speedbar========================
;; ==========================Start Load CEDET========================
; http://emacser.com/cedet.htm
; The CEDET package is a collection libraries, implementing different commands,
; but used for one goal — provide functionality for work with source code written in different programming languages:
;(load-file "/home/leosu/cedet-1.0pre6/common/cedet.el")
(load-file "/home/leosu/cedet-1.1/common/cedet.el")
;;我的是(load-file "/home/leosu/cedet-1.1/common/cedet.el")
;; Key bindings
(defun my-cedet-hook ()
;;Semantic-IA CEDET提供了几种补全的UI,可供选用,但是既然使用了auto-conplete 这些就变得可选了,
;;不过后来发现在弹出的menu中竟然可以用 Ctrl+n, p, f, b 进行导航,感觉还是比较爽的,所以把它们绑定到了 Ctrl+ENTR上了
;; Semantic-IA; 另一个选择就是Senator
;;(local-set-key [(control return)] 'semantic-ia-complete-symbol)
;;(local-set-key [(control return)] 'semantic-ia-complete-symbol-menu) ;自动补全 这是semantic的命令,它会根据分析结果弹出补齐的菜单,
;;(local-set-key [(control tab)] 'semantic-ia-complete-symbol-menu) ;自动补全 这是semantic的命令,它会根据分析结果弹出补齐的菜单,
;;(local-set-key [(control return)] 'semantic-ia-complete-symbol)
;;(local-set-key "/C-c?" 'semantic-ia-complete-symbol-menu) ;自动补全 这是semantic的命令,它会根据分析结果弹出补齐的菜单,
;; (local-set-key "/C-cd" 'semantic-ia-fast-jump)
;;(local-set-key "/C-cr" 'semantic-symref-symbol)
;;(local-set-key "/C-cR" 'semantic-symref)
;;
(local-set-key "\C-c>" 'semantic-complete-analyze-inline)
(local-set-key "\C-c=" 'semantic-decoration-include-visit)
(local-set-key "\C-cj" 'semantic-ia-fast-jump) ; 智能跳转 跳转到定义 only use here -->>leosu;
;(好像是从cedet1.0pre5才加入的)可以实现类似vs中f12的功能,跳转到光标所在的地方的符号的定义,我把它绑定到f12上了。
;如果跳不过去,那就检查一下前面配置的INCLUDE路径,是不是当前文件include(cedet-user-include-dirs)的所有头文件都能在INCLUDE中找到。
(local-set-key "\C-cq" 'semantic-ia-show-doc)
(local-set-key "\C-cs" 'semantic-ia-show-summary)
(local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) ;在函数的声明和实现之间来回跳转
; 不是这个功能不是十分准确,一般在cpp中函数实现处想跳到函数声明处正常,但是从声明处跳到实现处的话cedet不一定能找到cpp文件的位置。
(local-set-key (kbd "C-c <left>") 'semantic-tag-folding-fold-block)
(local-set-key (kbd "C-c <right>") 'semantic-tag-folding-show-block)
(local-set-key "\C-ct" 'eassist-switch-h-cpp) ;头文件和源文件之间跳转的快捷键
(local-set-key "\C-xt" 'eassist-switch-h-cpp) ;头文件和源文件之间跳转的快捷键
(local-set-key "\C-ce" 'eassist-list-methods)
(local-set-key "\C-c\C-r" 'semantic-symref) ;;查找光标所在处的符号
)
(add-hook 'c-mode-common-hook 'my-cedet-hook)
(add-hook 'lisp-mode-hook 'my-cedet-hook)
(add-hook 'scheme-mode-hook 'my-cedet-hook)
(add-hook 'emacs-lisp-mode-hook 'my-cedet-hook)
;(add-hook 'erlang-mode-hook 'my-cedet-hook)
;; ==========================end Load CEDET========================
;; ==========================Start Load EDE 还是使用ECB吧, ECB更好用========================
;; EDE; 使用项目管理组件 - ede 用来管理项目,它可以把emacs模拟得像一个IDE那样,把一堆文件作为一个project来管理。
; EDE is an Emacs Lisp program which implements an environment similar to those found in IDEs (Integrated Development Environment)
; implements set of extensions to work with projects — user can control list of the targets to build, build the project, etc.
; Besides this, using the notion of the project,
; you can have more precise control about Semantic's operations — name completions, navigation, and so on;
(global-ede-mode 1) ;Enable the Project management system
; EDE会在emacs中加一个叫做“Project”的菜单:
; 通过菜单可以创建project,往project里添加/移除文件;还可以编译project,不过好像只能通过已有的Makefile编译。
; 另外EDE还可以通过Speedbar显示整个project的目录树(见右边的Speedbar):
; EDE可以支持四种类型的project: Automake 手工写的Makefile C++ Root project Simple project
; 并且EDE能解析Autoconf/Automake,如果打开一个文件时在当前或者上级目录中能找到Makefile.am文件,EDE会自动解析文件(认为这是一个Automake的project),
; 识别出Makefile.am中定义的target和编译需用到的文件;打开目录树的话EDE能由Makefile.am中涉及到的文件生成目录树(上图的目录树就是EDE通过Makefile.am自动生成的)。
; 为了让semantic找到C/C++的头文件,前面是通过调用semantic-add-system-include把系统中可能出现的INCLUDE目录都告诉semantic的来实现的。
; 其实semantic还可以通过EDE识别project中特定的INCLUDE目录,方法是在.emacs文件中定义C++ Root project,比如:
;(setq libutil-project
; (ede-cpp-root-project "webkit"
; :system-include-path '("/mnt/dev_iptv/DEV_webkit_binary_integration"
; "/mnt/dev_iptv/DEV_webkit_binary_integration/extension"
; "/mnt/dev_iptv/DEV_webkit_binary_integration/hal")))
;(setq test-project
; (ede-cpp-root-project "test"
; :file "~/test/Makefile"
; :system-include-path '("/test/include"
; "/usr/include/boost-1.42")))
;; ==========================Start Load EDE========================
;; ==========================Start Load SRecode========================
;; SRecode是一个模板系统,通过一些预定义的模板,可以很快地插入一段代码。个人觉得这个功能跟msf-abbrev和yasnippet的功能有些类似。
;; Enable SRecode (Template management) minor-mode.
; Enable template insertion menu
;package for source code generation, using syntactic information (including information, extracted by Semantic);
(global-srecode-minor-mode 1)
;; ==========================End Load SRecode========================
;; ==========================Start 可视化书签========================
; emacs有自带的书签功能(c-x r m, c-x r b, c-x r l),不过对于用了多年VC6的我来说还是更习惯让一个书签能高亮显示出来。
; cedet里就带了一个可视化的书签,通过下面的语句可以启用它:
(enable-visual-studio-bookmarks)
; 之后就可以通过下面几个按键操作书签了: 有点遗憾的是这个书签功能只能在当前buffer的书签间跳转。
; F2 在当前行设置或取消书签
;C-F2 查找下一个书签
;S-F2 查找上一个书签
;C-S-F2 清空当前文件的所有书签
;; ==========================Start 可视化书签========================
;=========================start semantic related============================
; Semantic is an infrastructure for parser based text analysis in Emacs.
; Semantic应该是cedet里用得最多的组件了,代码间跳转和自动补全这两大功能都是通过semantic来实现的。
;; 为了方便使用,Semantic中提供了五种打包好的配置, 在速度和功能方面有所差异,任选一个即可:
;;;from http://blog.csdn.net/intrepyd/article/details/4331877
;;;https://github.com/alexott/emacs-configs/blob/master/rc/emacs-rc-cedet.el
; 功能属性,从上到下功能越来越少,性能越来越快 Select one of the following:
; 这些函数会自动帮你enable某些minor mode,大概有这么几个:
;(semantic-load-enable-semantic-debugging-helpers)
(semantic-load-enable-excessive-code-helpers)
(semantic-load-enable-guady-code-helpers)
(semantic-load-enable-code-helpers)
(semantic-load-enable-minimum-features)
;设置semantic分析文件的程度,一共有5级,从上到下越来越复杂。
;semantic-load-enable-minimum-features是最低要求;
;semantic-load-enable-code- helpers稍复杂一点,主要是加了一个imenu菜单(不过这个菜单在windows和mac上都显示不出来);
;semantic-load- enable-guady-code-helpers加入了一些用处不大的功能,比如在第一行显示当前的函数等(这个命令已经不建议使用了);
;semantic-load-enable-excessive-code-helpers加了在mode line显示当前函数名的功能,也没多大用;
;semantic-load-enable-semantic-debugging-helpers用于调试 semantic本身。
;所以一般我们用semantic-load-enable-code-helpers就可以了。
;; Activate semantic
;(semantic-mode 1)
(setq semantic-mode t)
; 配置Semantic的检索范围:
; 如何跨文件跳转, 补全? Semantic会搜索一个project内的其它文件. 所以如果设定了
; 那么, ~/projects/bps目录及其子目录下的所有文件会被视为一个project, semantic 补全, 跳转时会搜索project中的其它文件
;; (setq semanticdb-project-roots (list (expand-file-name "~/projects/bps")))
(setq semanticdb-project-roots (list (expand-file-name "/mnt/dev_iptv/DEV_webkit_binary_integration/"))) ; leosu's project directory;
; semantic这种找法肯定会造成大量的头文件找不到的(找不到头文件还怎么解析啊),
; 因为我在Windows下可能用MinGW和VC6,所以我把它们的include目录都加进来了,要是你用别的编译器,就改成自己的目录好了
(defconst cedet-user-include-dirs
(list ".." "../include" "../inc" "../common" "../public"
"../.." "../../include" "../../inc" "../../common" "../../public"))
(defconst cedet-win32-include-dirs
(list "C:/MinGW/include"
"C:/MinGW/include/c++/3.4.5"
"C:/MinGW/include/c++/3.4.5/mingw32"
"C:/MinGW/include/c++/3.4.5/backward"
"C:/MinGW/lib/gcc/mingw32/3.4.5/include"
"C:/Program Files/Microsoft Visual Studio/VC98/MFC/Include"))
(require 'semantic-c nil 'noerror)
(let ((include-dirs cedet-user-include-dirs))
(when (eq system-type 'windows-nt)
(setq include-dirs (append include-dirs cedet-win32-include-dirs)))
(mapc (lambda (dir)
(semantic-add-system-include dir 'c++-mode) ;semantic默认只搜索当前路径,
(semantic-add-system-include dir 'c-mode)) ;semantic默认只搜索当前路径,
include-dirs))
;; 选择系统库的位置,如果你使用的是gcc,那么可以通过如下配置自动找到系统库:
(require 'semantic-gcc)
;; 或者手动添加,例如:
;(semantic-add-system-include "/usr/include" 'c-mode) ;semantic默认只搜索当前路径,
;(semantic-add-system-include "/usr/include" 'c++-mode)
;; 配置Semanticdb
;; 主要是配置semantic数据库的缓存位置:
(require 'semanticdb)
;(global-semanticdb-minor-mode 1) ;; has inclued in semantic-load-enable-minimum-features
; 设置semantic cache临时文件的路径,避免到处都是临时文件
; 设置cache文件的保存位置,不设的话默认是在被分析文件的目录下,每个目录一个。
(setq semanticdb-default-save-directory
(expand-file-name "/home/leosu/.emacs.d/.semanticdb"))
;; 选择Backends Semanticdb目前默认可以支持的后端是gtags和ctags,通过扩展库也可支持ebrowse和cscope(?)
(when (cedet-cscope-version-check t) ;Is it ok?
;; Configurations for CScope and CEDET.
(semanticdb-enable-cscope-databases 'c-mode)
(semanticdb-enable-cscope-databases 'c++-mode)
(setq ede-locate-setup-options
'(ede-locate-cscope ede-locate-base))
)
;; if you want to enable support for gnu global
;(when (cedet-gnu-global-version-check t)
; (require 'semanticdb-global)
; (semanticdb-enable-gnu-global-databases 'c-mode)
; (semanticdb-enable-gnu-global-databases 'c++-mode))
;; enable ctags for some languages:
;; Unix Shell, Perl, Pascal, Tcl, Fortran, Asm
;(when (cedet-ectag-version-check t)
; (semantic-load-enable-primary-exuberent-ctags-support))
;(when (cedet-ectag-version-check t)
; (semantic-load-enable-primary-ectags-support))
;;;; 使函数体能够折叠或展开
; 只要用鼠标点击左侧的小三角图标就可以打开或折叠代码了。箭头向下的空心三角表示这段代码可以被折叠,箭头向右的实心三角表示这段代码被打折过了。
;; Enable source code folding
(require 'semantic-tag-folding nil 'noerror)
(global-semantic-tag-folding-mode 1)
; 为了方便键盘操作,我把按键绑定到了[C-c , -]和[C-c , +]上(绑定这么复杂的; 按键主要是为了和senator兼容,后面会讲到senator实现代码折叠):
(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)
; 同时它还提供了两个函数可以同时打开和折叠整个buffer的所有代码,分别是 semantic-tag-folding-fold-all和semantic-tag-folding-show-all,
; 我把它们绑定到了[C-_]和[C-+]上:
;(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))
; 打开semantic-tag-folding-mode后,用gdb调试时不能点左侧的fringe切换断点了,
; 所以我把C-?定义为semantic-tag-folding-mode的切换键,在gdb调试时临时把semantic-tag-folding关掉:
; (global-set-key (kbd "C-?") 'global-semantic-tag-folding-mode)
;;;;自动补齐策略
; semantic-ia调用semantic-analyze-possible-completions函数来取得可能的补全内容,它能为用户提供精确的补全列表;
; 而senator用了一个更简单的的函数来获取补全内容,所以有可能会提供错误的结果。”
; semantic中有4个用来代码补全的命令:
; senator-complete-symbol senator-completion-menu-popup semantic-ia-complete-symbol semantic-ia-complete-symbol-menu
; senator-complete-symbol和semantic-ia-complete-symbol这两个函数是新开一个buffer提示可能的补全内容;
; 而senator-completion-menu-popup和semantic-ia-complete-symbol-menu会弹出一个补全菜单
; 也就是说semantic-ia的补全更智能一些。
; 至于semantic-ia这两个补全选哪一样就看各人喜好了,我喜欢用semantic-ia-complete-symbol-menu,因为看起来更直观一些,像这样:
; 不过semantic-ia-complete-symbol-menu只能用于GUI下,要是在终端下,就只能用semantic-ia-complete-symbol了。
; 如果你用cedet不能补全,检查一下semantic是不是已经启用了,我的emacs上经常出现第一次打开c++-mode时semantic没自动启用的情况。
; 看semantic是否正常有个直观的方法就是senator,如果启用了senator-minor-mode,打开c++文件时emacs会出现Senator菜单,
; 如果没有Senator菜单你可以关掉再重新打开试试,要是仍然不出现菜单那就得检查配置是不是有问题。
; 如果确认semantic启用了仍然不能补全,就需要检查INCLUDE路径的配置,通过C-h v semantic-dependency-system-include-path RET检查INCLUDE路径,
; 确保当前cpp中直接或间接include的头文件都能在INCLUDE路径中找到。
; 下面是Senator 的相关自动补齐配置
;(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)
;;; Semantic-IA; 另一个选择就是Senator,这个Semantic组件提供了一些补全函数,可以用在 hippie expand 或者 auto complete中:
;;; I will use Semantic-IA; leosu; will not use senator
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-function-list
'(
jde-complete-generic
senator-try-expand-semantic;semantic complete
try-expand-dabbrev-visible;dynamic abbrevation - visible part
try-expand-dabbrev;dynamic abbrevation - this buffer
try-expand-dabbrev-all-buffers;dynamic abbrevation - all buffers
try-expand-dabbrev-from-kill ;dynamic abbrevation - from kill buffers
try-complete-file-name-partially ;complete file name
try-complete-file-name ;complete full file name
try-expand-all-abbrevs ;expand abbrevations
try-expand-list ;list beginning
try-expand-line ;line in the buffer
try-complete-lisp-symbol-partially ; try emacs lisp symbols
try-complete-lisp-symbol)
)
;; Integration with imenu
;;The Semantic package can be integrated with the imenu package.
;;This lead to creation of a menu with a list of functions, variables, and other tags.
;;To enable this feature you can either use semantic-load-enable-code-helpers,
;;or you need to add following code into your initialization file:
(defun my-semantic-hook ()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)
;;;; 当输入"."或">"时,在另一个窗口中列出结构体或类的成员; 自动补全
;(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)
;=========================end semantic related============================
;; =====================Load ecb 加载ECB ecb depanded cedet.================
;; /home/leosu/ecb-2.40 # vim Makefile /home/leosu/ecb-2.40 # vim ecb-upgrade.el
;; 版本问题解决方案:http://blog.csdn.net/cnsword/article/details/7474119
(add-to-list 'load-path "/home/leosu/ecb-2.40")
;;例如(add-to-list 'load-path "~/.emacs.d/ecb-2.32")
(require 'ecb)
(require 'ecb-autoloads)
(setq stack-trace-on-error t)
;(setq ecb-auto-activate t);自动启动ecb
;(setq ecb-auto-activate t;自动启动ecb
;ecb-tip-of-the-day nil;不显示每日提醒
;inhibit-startup-message t;不知道什么意思,望各位指导
;ecb-auto-compatibility-check nil;
;ecb-version-check nil;
;)
;;关掉每日提示
;(setq ecb-tip-of-the-day nil)
;; 隐藏和显示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 停止ecb
;(global-set-key [f8] 'ecb-activate) ;;定义F8键为激活ecb
;(global-set-key [f9] 'ecb-deactivate) ;;定义F9为停止ecb
(global-set-key [(control f8)] 'ecb-activate) ;;定义F8键为激活ecb
(global-set-key [(control f9)] 'ecb-deactivate) ;;定义F9为停止ecb
;; =====================end Load ecb 加载ECB ecb depanded cedet.================
;; 编译和调试程序
; 写完程序和Makefile文件后,在Emacs源代码窗口中按F7就可以进行编译。因为在my-c-mode-common-hook()函数里,有这么一行:
;(define-key c-mode-base-map [(f7)] 'compile)
;默认情况下,emacs的compile命令是调用make -k,我把它改成了make。你也可以把它改成其他的,比如gcc之类的。改下面的“make”就行了。
;;修改默认make -k 命令
(setq compile-command "make")
; Emacs会划分一个窗格显示编译的消息,在编译结束后,emacs会自动将编译器的输出和程序关联起来,告诉你第几行的程序有问题。
; 直接在出错的行号上按Enter,就可以跳转到相应文件的相应行。其实我通常都是用鼠标中键去点出错行号:)
; 下面的命令就可以启动gdb了; M-x gdb
; 通常我喜欢进入gdb-many-windows模式,这样就会把一个Frame划分为5个窗格,同时显示:gdb命令窗口,当前局部变量,程序文本,调用栈和断点。
; gdb的命令就不在这里说了,它的文档几乎到处都是。emacs把gdb的命令和快捷键做了绑定,对于常用的命令,还是输入快捷键比较方便。
; 比如,C-c C-n是Next line,C-c C-s是step in,其实用的最多的快捷键也就是这两个。
;; start gdb
(global-set-key [f8] 'gdb)
;; toggle gdb-many-windows 为gdb-many-windows绑定快捷键
(add-hook 'gdb-mode-hook
'(lambda ()
(local-set-key [(f9)] 'gdb-many-windows)
)
)
(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.
)