emacs打造开发环境

安装emacs

sudo apt-get install emacs25

copy大神通用配置

git clone https://github.com/purcell/emacs.d.git ~/.emacs.d

打造C/C++开发环境

CEDET

CEDET 是 Collection of Emacs Development Environment Tools的缩写, 意为”Emacs开发环境工具集”,其主要目的是在Emacs中建立一个高级的开发环境。 它主要包括下列组件:

  • Semantic -— 多种编程语言的语法分析的基础组件。
  • SemanticDB-—包含在Semantic中的一个数据库,用于保存代码的语法、接口等等信息。
  • Senator -— 通过Semantic提取出来的信息构成的代码文件中的navegation。
  • Srecode -— 代码生成组件。
  • EDE -— 提供工程管理相关功能;
  • Speedbar -— 用于显示当前Buffer的侧边栏。
  • Eieio is a library, implementating CLOS-like (Common Lisp Object System) infrastructure for Emacs Lisp;
  • Cogre is a library for drawing of UML-like diagrams in Emacs buffer, with basic integration with Semantic.

CEDET已经在emacs中内置,不用安装,只需要配置下
具体的配置说明可以参考http://www.cr173.com/html/8148_1.html

ECB

ECB(Emacs Code Browser),emacs下代码浏览器,提供了下面的功能:

  • 目录树
  • 当前目录下的文件
  • 当前文件中的class、func
  • history打开记录

看一下最后的效果图吧:
emacs打造开发环境_第1张图片

贴出我新加的配置文件

;;; init-local.el

;;; user
(setq user-full-name "hewei")
(setq user-mail-address "[email protected]")

;;; custom
(setq-default cursor-type 'bar)
(global-linum-mode t)

;;; CEDET
(require 'cedet)
(semantic-mode t)
(global-ede-mode t)
;;;; Mark settings
(defadvice push-mark (around global-semantic-mru-bookmark-mode activate)
  (semantic-mrub-push semantic-mru-bookmark-ring
                      (point)
                      'mark)
  ad-do-it)
(global-semantic-idle-summary-mode t)
(global-semantic-stickyfunc-mode t)
;;;; Include settings
(require 'semantic/bovine/gcc)
(require 'semantic/bovine/c)

(defconst cedet-user-include-dirs
  (list ".." "../include" "../inc" "../common" "../public" "."
        "../.." "../../include" "../../inc" "../../common" "../../public"))

(setq cedet-sys-include-dirs (list
                              "/usr/include"
                              "/usr/include/bits"
                              "/usr/include/glib-2.0"
                              "/usr/include/gnu"
                              "/usr/include/gtk-2.0"
                              "/usr/include/gtk-2.0/gdk-pixbuf"
                              "/usr/include/gtk-2.0/gtk"
                              "/usr/local/include"
                              "/usr/local/include"))

(let ((include-dirs cedet-user-include-dirs))
  (setq include-dirs (append include-dirs cedet-sys-include-dirs))
  (mapc (lambda (dir)
          (semantic-add-system-include dir 'c++-mode)
          (semantic-add-system-include dir 'c-mode))
        include-dirs))

(setq semantic-c-dependency-system-include-path "/usr/include/")


;;; kbd
(global-set-key (kbd "") 'semantic-ia-fast-jump)
(global-set-key (kbd "S-") 'semantic-mrub-switch-tags)
(global-set-key (kbd "C-") 'semantic-symref)
(global-set-key (kbd "") 'ecb-minor-mode)
(global-set-key (kbd "") 'eshell)

(global-set-key (kbd "C-r") 'anzu-query-replace)
(global-set-key (kbd "C-o") 'cua-set-mark)
(global-set-key (kbd "C-z") 'undo-tree-undo)
(global-set-key (kbd "C-x k") 'kill-this-buffer)

;;; indent
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq c-default-style "cc-mode")
(setq c-basic-offset 4)

(provide 'init-local)
;;; end

你可能感兴趣的:(emacs,c-c++,开发环境,cedet,ecb,linux)