(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.
'(current-language-environment "UTF-8"))
(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.
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;---------------------- UI -------------------------
;; plugins directory
(add-to-list 'load-path "~/.emacs.d/lisp")
;; 标题栏,显示"buffer的名字@Emacs"
(setq frame-title-format "%b@Emacs")
;; 禁用启动信息
(setq inhibit-startup-message t)
;; 显示光标位置
(setq column-number-mode t)
(setq line-number-mode t)
;; 设置kill-ring-max为200
(setq kill-ring-max 200)
;; 设置tab为4个空格的宽度,而不是原来的2
(setq c-basic-offset 4)
(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)
;; 设置让光标指到某个括号与它匹配的括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;; 禁用终端响铃
(setq visible-bell t)
;; 高亮显示选择区域
(setq transient-mark-mode t)
;; 显示日期时间
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-interval 10)
(display-time)
;; 不产生备份文件,临时文件
(setq make-backup-files nil)
(setq-default make-backup-files nil)
;; 防止页面滚动时跳动
(setq scroll-margin 3
scroll-conservatively 10000)
;; 保存上次的操作记录到SESSION: http://emacs-session.sourceforge.net/
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
;; 给每行显示行号: http://stud4.tuwien.ac.at/~e0225855/linum/linum.html
(require 'linum)
(global-linum-mode t)
;; 颜色主题: http://download.gna.org/color-theme/
(require 'color-theme)
(color-theme-initialize)
(color-theme-midnight)
;; 'y' for 'yes', 'n' for 'no'
(fset 'yes-or-no-p 'y-or-n-p)
;; 代码折叠:
;; http://www.gnuvola.org/software/j/hideshow/
(load-library "hideshow")
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'c++-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;; 代码缩进风格
(defconst my-c-style
'("BSD" ;;基于现有的代码风格进行修改。
(c-offsets-alist . ((case-label . *)
(statement-case-intro . *))))
"My Programming Style")
;; 将自定义的代码风格加入到列表中
(c-add-style "myBSD" my-c-style)
(setq c-default-style '((c++-mode . "myBSD")
(c-mode. "myBSD")
(java-mode . "java")
(awk-mode . "awk")
(other . "gnu")))
;; :http://code.google.com/p/yasnippet/
(require 'yasnippet-bundle)
;; 给Emacs添加Tab功能: http://emhacks.sourceforge.net/
(require 'tabbar)
(tabbar-mode 1)
(setq tabbar-buffer-groups-function
(lambda (buffer)
(list "All buffers")))
(global-set-key (kbd "M-[") 'tabbar-backward-group)
(global-set-key (kbd "M-]") 'tabbar-forward-group)
(global-set-key (kbd "M-p") 'tabbar-backward-tab)
(global-set-key (kbd "M-n") 'tabbar-forward-tab)
(global-set-key [(control tab)] 'tabbar-forward-tab)
;; 隐藏滚动条
(scroll-bar-mode -1)
;; 打开图片显示功能
(auto-image-file-mode t)
;; 支持emacs和外部程序的粘贴
(setq x-select-enable-clipboard t)
;;;;----------------- Programming ------------------------
;; CEDET: http://cedet.sourceforge.net/
(load-file "~/.emacs.d/lisp/cedet/common/cedet.el")
(semantic-load-enable-excessive-code-helpers)
;;(semantic-load-enable-semantic-debugging-helpers)
(setq semanticdb-default-save-directory "~/.emacs.d/")
(setq senator-minor-mode-name "SN")
(setq semantic-imenu-auto-rebuild-directory-indexes nil)
(global-srecode-minor-mode 1)
(global-semantic-mru-bookmark-mode 1)
;; if you want to enable support for gnu global
(require 'semanticdb-global)
;;(global-semantic-folding-mode 1)
(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
;;(semantic-load-enable-primary-exuberent-ctags-support)
(require 'semantic-decorate-include)
;; gcc setup
(require 'semantic-gcc)
;; smart complitions
(require 'semantic-ia)
(setq-mode-local c-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(setq-mode-local c++-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(setq-mode-local erlang-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(require 'eassist)
;; customisation of modes
(defun my-cedet-hook ()
(local-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-c?" 'semantic-ia-complete-symbol)
(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)
(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)
)
;;(add-hook 'semantic-init-hooks 'my-cedet-hook)
(add-hook 'c-mode-common-hook 'my-cedet-hook)
(add-hook 'lisp-mode-hook 'my-cedet-hook)
(add-hook 'emacs-lisp-mode-hook 'my-cedet-hook)
;; (add-hook 'erlang-mode-hook 'my-cedet-hook)
(defun my-c-mode-cedet-hook ()
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert)
(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-c-mode-cedet-hook)
;; hooks, specific for semantic
(defun my-semantic-hook ()
;; (semantic-tag-folding-mode 1)
(imenu-add-to-menubar "TAGS")
)
(add-hook 'semantic-init-hooks 'my-semantic-hook)
(custom-set-variables
'(semantic-idle-scheduler-idle-time 3)
'(semantic-self-insert-show-completion-function (lambda nil (semantic-ia-complete-symbol-menu (point))))
'(global-semantic-tag-folding-mode t nil (semantic-util-modes)))
;; ede customization
(require 'semantic-lex-spp)
(global-ede-mode t)
;; my functions for EDE
(defun my-ede-get-local-var (fname var)
"fetch given variable var from :local-variables of project of file fname"
(let* ((current-dir (file-name-directory fname))
(prj (ede-current-project current-dir)))
(when prj
(let* ((ov (oref prj local-variables))
(lst (assoc var ov)))
(when lst
(cdr lst))))))
;; setup compile package
;; TODO: allow to specify function as compile-command
(require 'compile)
(setq compilation-disable-input nil)
(setq compilation-scroll-output t)
(setq mode-compile-always-save-buffer-p t)
(defun My-Compile ()
"Saves all unsaved buffers, and runs 'compile'."
(interactive)
(save-some-buffers t)
(compile (or (my-ede-get-local-var (buffer-file-name (current-buffer)) 'compile-command)
compile-command)))
;;; emacs-rc-cedet.el ends here
;;Cedet's configuration for work with Qt4
(setq qt4-base-dir "/usr/include/qt4")
(semantic-add-system-include qt4-base-dir 'c++-mode)
(add-to-list 'auto-mode-alist (cons qt4-base-dir 'c++-mode))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qconfig.h"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qconfig-dist.h"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qglobal.h"))
;;;;-----------------------ecb config--------------------
(add-to-list 'load-path "~/.emacs.d/lisp/ecb/")
(require 'ecb-autoloads)
;;;;-----------------------cscope config------------------
(require 'xcscope)
;;;;---------------- Personal Info. ----------------------
(setq user-full-name "peng530")
(setq user-mail-address "
[email protected]")
;;;;---------------- Global Hot Key ----------------------
;; F1:最大化当前buffer:
(global-set-key [(f1)] 'delete-other-windows)
;; F2:切换到dired模式
(global-set-key [(f2)] 'dired)
;; F3:切换到shell模式
(global-set-key [(f3)] 'ansi-term)
;; F4:关闭buffer
(global-set-key [(f4)] 'kill-buffer-and-window)
;; F5:打开speedbar
(global-set-key [(f5)] 'speedbar)
;; 跳到另一个窗口
(global-set-key [(f6)] 'other-window)
;; F7:编译
(global-set-key [(f7)] 'My-Compile)
;; F9:gdb
(global-set-key [(f9)] 'gdb)
;; F10: gdb:next
(global-set-key [(f10)] 'gud-next)
;; F11: gdb:step
(global-set-key [(f11)] 'gud-step)