程序员的emacs配置大全(cedet+ecb+cscope+gdb-ui)-jzj

Emacs打造成阅读源代码的神器 StartEmacs是一个功能相对较多而且很复杂的text­editor,所以想要熟练使用必须要对emacs的一些基本概念进行了解,了解这些概念最好的教程就是emacs自带的 “Emacs Tutorial“。可以通过点击菜单栏的Help->Emacs Tutorial(choose language)进行学习。将Emacs打造成舒适的代码阅读器要想将Emacs打造成舒适的代码阅读环境除了需要Ema 阅读详情
本文主要讨论以下几方面的设置:
1.字体
2.cedet
3.ecb
4.cscope
5.gdb-many-window
6.行号
7.缩进

 
环境:
openSUSE 10.2
默认装的是Emacs 21,我从网上下了Emacs 22.1的tar包,编译安装。
1.字体
    默认的字体非常之小,以下是一篇非常详细的Emacs下设置字体的教程
http://www.yuanma.org/data/2006/0503/article_355.htm
可惜太长了,长到我实在是懒得看。我抄了个现成的:
(set-default-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso10646-1")
或者只写:
(set-default-font "10x20")
第二种方法效果不错:)
2.cedet
   下载cedet:  http://cedet.sourceforge.net/
按照INSTALL安装就行,然后设置.emacs。INSTALL里有一段关于设置的,粘贴过来即可,另外最好在.emacs中设一个speedbar的快捷键:
(global-set-key [(f4)] 'speedbar-get-focus)
这样按一个F4,speedbar就出来了。
再加一条:
  (define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
于是,在程序中按下Alt+/,就会弹出菜单让你自动补全。

3.ecb
     http://ecb.sourceforge.net/
.emacs里:
(add-to-list 'load-path "~/software/ecb-2.32")
;;(require 'ecb)
(require 'ecb-autoloads)
打开emacs,然后M-x ecb-activate即可打开ecb。
4.cscope
   这个应该和ecb的有些功能是重复的
先装好cscope,再把/cscope-15.6/contrib/xcscope目录下的xcscope.el加载到emacs中去:
(add-to-list 'load-path "~/software/cscope-15.6/contrib/xcscope")
(require 'xcscope)
之后先M-x !,然后cscope -b,之后就可以在源代码中进行跳转了。命令见cscope菜单
这里有篇讲怎么在emacs下安装和使用cscope的:
http://ann77.stu.cdut.edu.cn/EmacsCscope.html
5.gdb-many-window
   这个功能插件可以使emacs的调试界面像VC一样,有watch, stacktrace等窗口,真正实现图形化gdb.
下载:
http://www.inet.net.nz/~nickrob/multi-gud.el
http://www.inet.net.nz/~nickrob/multi-gdb-ui.el
设置.emacs:
(setq gdb-many-windows t)
;;...
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")
在emacs中编译好程序,然后M-x gdb,连按两次ret,多窗口gdb就出来了
还不行的看详细官方教程: http://www.inet.net.nz/
一遍使用gdb-ui的教程:
http://blog.chinaunix.net/u/5958/showart_137996.html

6.行号
见:
然后在.emacs里加上:
(add-to-list 'load-path "~/backup/emacs") ;;这行根据你放el文件的地方改
(require 'display-line-number)
(global-display-line-number-mode 1)
;;(setq display-line-number-mode-on t)
(add-hook 'c-mode-hook 'display-line-number-mode)
(add-hook 'cc-mode-hook 'display-line-number-mode)
这个感觉比setnu.el那个好用,setnu.el有时候行号会乱掉的。
7.缩进
emacs的缩进方式和其它编辑器有些不同,text-mode下不能tab,只能用C-q tab才行。
c-mode或cc-mode下缩进只有2格,这个当然不符合大多数人的习惯,如果要设为4:
(add-hook 'c-mode-hook
          '(lambda ()
             (c-set-style "Stroustrup")))
如果要设成8:
options->Customize Emacs->Browse Customization Group->Programming->Language->C->C-Basic-offset,设成8就行,保存
 
我的.emacs文件,供参考(比较乱,没整理过):
(setq initial-frame-alist '((top . 0) (left . 0) (width . 1024) (height . 768)))


(column-number-mode t)
(transient-mark-mode t)
(setq line-number-mode t)
(setq default-tab-width 8)

(customize-set-variable 'scroll-bar-mode' right)
;;(setq default-directory "home/jzj/backup/emacs/")
(setq inhibit-startup-message t)
(setq global-font-lock-mode t)
(setq make-backup-files nil)
(setq auto-save-mode nil)
(setq x-select-enable-clipboard t)
(setq mouse-yank-at-point t)
;;(global-set-key [home] 'beginning-of-buffer)

;;(global-set-key [end] 'end-of-buffer)
(global-set-key [f3] 'display-line-number-mode-on)
;;(global-set-key [f4] 'other-window)
(global-set-key [f5] 'compile)
(setq-default compile-command "make")
;;(global-set-key [f7] 'du-onekey-compile)
(global-set-key [f6] 'gdb)
(global-set-key [C-f7] 'previous-error)
(global-set-key [f7] 'next-error)

;;(set-default-font "9x15")
;;(set-default-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso10646-1")
(set-default-font "10x20")
;;(set-default-font "-outline-新宋体-normal-r-normal-normal-14-*-96-96-c-*-gb2312")

;; Load CEDET
(load-file "~/software/cedet-1.0pre4/common/cedet.el")

;; Enabling various SEMANTIC minor modes.  See semantic/INSTALL for more ideas.
;; Select one of the following:

;; * This enables the database and idle reparse engines
;;(semantic-load-enable-minimum-features)

;; * This enables some tools useful for coding, such as summary mode
;;   imenu support, and the semantic navigator
;;(semantic-load-enable-code-helpers)

;; * This enables even more coding tools such as the nascent intellisense mode
;;   decoration mode, and stickyfunc mode (plus regular code helpers)
;;(semantic-load-enable-guady-code-helpers)

;; * This turns on which-func support (Plus all other code helpers)
(semantic-load-enable-excessive-code-helpers)

;; This turns on modes that aid in grammar writing and semantic tool
;; development.  It does not enable any other features such as code
;; helpers above.
(semantic-load-enable-semantic-debugging-helpers)

(global-set-key [(f4)] 'speedbar-get-focus)

(require 'cc-mode)
(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 8 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 [(f6)] '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)
  
  (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)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(defun my-c++-mode-hook()
  (setq tab-width 8 indent-tabs-mode nil)
  (c-set-style "stroustrup")
;;  (define-key c++-mode-map [f3] 'replace-regexp)
)

(setq gdb-many-windows t)

(add-to-list 'load-path "~/backup/emacs")
(require 'gud)

(require 'display-line-number)
(global-display-line-number-mode 1)
;;(setq display-line-number-mode-on t)
(add-hook 'c-mode-hook 'display-line-number-mode)
(add-hook 'cc-mode-hook 'display-line-number-mode)

(add-to-list 'load-path "~/software/ecb-2.32")
;;(require 'ecb)
(require 'ecb-autoloads)

;;for gdb-many-window mode
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")

;; cscope in emacs
(add-to-list 'load-path "~/software/cscope-15.6/contrib/xcscope")
(require 'xcscope)

;; hotkey for cscope
(define-key global-map [(control f3)]  'cscope-set-initial-directory)
(define-key global-map [(control f4)]  'cscope-unset-initial-directory)
(define-key global-map [(control f5)]  'cscope-find-this-symbol)
(define-key global-map [(control f6)]  '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)

(set-face-background 'default "#334455")
(set-face-foreground 'default "wheat")
(set-cursor-color "white")


;;(add-to-list 'load-path "~/software/color-theme-6.6.0")
;;(require 'color-theme)
;;(color-theme-dark-blue)
LTE随机接入实战:如何通过PRACH前导码优化小区覆盖半径(附计算公式) 本文深入探讨了LTE网络中PRACH前导码格式对小区覆盖半径的关键影响。通过解析不同前导码格式(如Format 0-3)的物理参数与覆盖能力,提供了核心计算公式与实战Python脚本,指导网络工程师根据覆盖需求、环境多径和容量等因素,科学选择前导码格式以优化边缘用户接入成功率,实现精准的网络规划与优化。 阅读详情

相关推荐

OpenCV实战系列——图像线条提取

基于内容的图像分析,需要从构成图像的像素集合中提取有意义的特征。轮廓、线条、区域等是基本的图像基元,可用于描述图像中包含的元素。本节将介绍如何提取重要的图像线条特征。

m0_58523831的博客 1万+

GDB常用命令与技巧(超好用的图形化gdbgui

目录 一、常用命令 二、调试脚本 三、图像界面 一、常用命令 命令 命令缩写 命令说明 list l 显示多行源代码 break b 设置断点 break if b if 当满足某个条件时停止 delete d 删除断点(包括watch 点),一般先使用info命令...

Likes的博客 2万+

DebuGui - GDB UI:易于使用的GDB GUI-开源

该项目试图解决一个长期的难题,即缺少一个简单但功能强大的GDB GUI。 一种处理STL数据类型并易于扩展的方法。 要求:Python 2.7.x PySide(Qt python绑定:例如apt-get install python-pyside)

emacs中使用ecb

ecbemacs中使用一个代码浏览器,使用它可以方便地查看文件,函数,以及在代码间方便地跳转,在debian中的安装极其简单,直接apt-get install ecb即可.安装完后不用任何设置,打开emacs,执行M-xecb-activate即可打开ecb,默认左边会出四个窗口,现在打开任意一个程序文件,左边的窗口会发生变化,第一个窗口显示当前文件夹列表,第二个窗口显示当前文件所

meteor1113的专栏 2950

Emacs+cscope手动创建索引(感受cscope的强大)(八十三)

cscope 创建索引.创建索引文件列表cscope.files注意:cscope在产生索引文件时,只搜索类型为C, lex和yacc的文件(后缀名为.c, .h, .l,.y),C++的文件根本没有生成索引。所以需要find手动指定。查看下cscope.files文件列表.为cscope.files中的每个文件都生成索引函数此命令会生成三个文件:cscope.out, cscope.in.out, cscope.po.out。

Android系统攻城狮 547

Emacs + ecb使用(Emacs必须24.3以上版本)(三十四)

1、ecb使用需要依赖于cedet,请移步:cedet安装步骤 2、下载ecb: git clone https://github.com/alexott/ecb/ 3、将下载好的ecb目录拷贝到~/.emacs.d目录 # cp -rf ecb ~/.emacs.d 4、配置.emacs ;ecb (add-to-list 'load-path "~/.emacs.d/ec

Android系统攻城狮 2152

GDB调试器

编译带调试信息的程序 # 禁用编译器优化,便于查阅代码时对齐 gcc -g hello.c -o hello -O0 # 移除调试信息 strip hello 启动调试 调试未启动的程序 gdb hello 调试已启动的程序 # 获取进程PID ps -ef | grep hello # attach 进程 gdb attach 进程PID # 结束调试,gdb和程序分离,程序继续运行 detach quit 常用命令 tbreak 添加一个临时断点,断点一旦被触发就会被自动删除 b

肥宅不死的博客 577

emacs配置大全(cedet+ecb+cscope+gdb-ui)-jzj

本文主要讨论以下几方面的设置:1.字体2.cedet3.ecb4.cscope5.gdb-many-window6.行号7.缩进 环境:openSUSE 10.2默认装的是Emacs 21,我从网上下了Emacs 22.1的tar包,编译安装。1.字体    默认的字体非常之小,以下是一篇非常详细的Emacs下设置字体的教程http://www.yuanma.org/data/2006

嵌入式系统,linux,存储 1万+

emacs配置

为了更好的使用emacs编程,需要安装插件。 一、安装好GNU Emacs 23.1.1 二、安装cedet-1.0pre6。安装cedet时,直接将其解压到硬盘上,然后在shell中进入此目录,按照INSTALL文件的指示执行sudo make,然后增加.emacs相关内容。 三、安装ecb 2.40。只需将其解压到硬盘,修改相关.emacs文件内容即可。 四、安装cscope 15.7a。将其解压到硬盘,按照INSTALL文件指示依次执行sudo ./configure、sudo m

Matrix_Designer的专栏 751

emacsecbcedet

在 sf.net 搜索ecbcedet 并且下载加压到自己的目录 加入 如下配置代码 [code="lisp"] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Cedet 1.1 ;; (load-file "~/.emacs.d/plugins/cedet-1.1/common/cedet.el") (global-ede-mod...

jianghao19890829的专栏 351

emacs 中的 cscope

简介对于浏览源代码来说,在 Emacs 里面也有很多工具可用,比如自带的 etags 就 不错,不过功能不如 Cscope 强大。 Cscope 并不像 etags 那样属于 Emacs , 它是一个独立的程序。它是一个具有完全 Unix 血统的程序,用于帮助开发人员 浏览源代码。它最初(那还是 PDP-11 的时代)是由 Bell 实验室开发,并且多年 以来一直是 AT&T Unix

嵌入式系统,linux,存储 1296

【亲测免费】 推荐开源项目:GDBGUI - 浏览器前端的GNU调试神器

THE 0TH POSITION OF THE ORIGINAL IMAGE 想要在浏览器中轻松地进行程序调试吗?GDBGUI正是你需要的工具!这是一个基于Web的前端界面,专为著名的GNU Debugger(GDB)打造,让你可以在任何支持HTML5的现代浏览器中远程或本地进行调试工作。 ## 项目技术分析 GDBGUI的核心是将传统的命令行调试体验转化为直观易用的图形化界面。它采用Pyt...

gitblog_00009的博客 774

GDB图形界面大PK

gdb虽然很强大,但是却略显单调。其实gdb有很多前端图形界面。那么选哪个呢?请看GDB图形界面大PK。 原文:http://shenyu.wikiTUIgdb原生的图形模式,支持gdb所有的特性。使用方法:gdb attach pid 之后ctrl+x acgdbhttp://cgdb.github.io/可以认为是TUI模式的增强版,具有代码高亮、查找等等功能。同时也支持gdb所有的特性。 如

小宇的博客 1万+

emacs + cscope 的使用

1.首先到  http://cscope.sourceforge.net 下载cscope 2.安装:      tar -zxf cscope-xx.x.tar.gz      cd cscope-xx.x      ./configure      make      make install     然后把contib/xcscope/目录下的cscope-indexer复

技术的学习与积累是个技术活 2084

cscopeemacs里的使用

在windows下通常使用source insight阅读源代码,本人希望将这项工作转移到linux下面。在配置并试用vim一段时间后,感觉不是特别满意。幸运的是,这个挑剔的人并不懒惰,开始尝试使用强大的emacs。在这里,并不介绍emacs的基本操作以及配置,建议学习emacs自带的帮助或者阅读《学习GNU Emacs》,而是与大家分享cscopeemacs中的配置与使用。 作为菜鸟在开源世

石头 671

Emacs里面使用Cscope

Emacs 里面使用 Cscope Contents 简介 安装和配置 使用简介 简介 对于浏览源代码来说,在 Emacs 里面也有很多工具可用,比如自带的 etags 就不错,不过功能不如 Cscope 强大。 Cscope 并不像 etags 那样属于 Emacs ,它是一个独立的程序。它是一个具有完全 Unix 血统的程序,用于帮助开发人员浏览源代码。...

weixin_34150224的博客 147

GDB调试之TUI界面

TUI(TextUserInterface)为GDB调试的文本用户界面,可以方便地显示源代码、汇编和寄存器文本窗口,TUI使用效果如下图所示。 Tui界面可以通过运行gdbtuigdb-tui命令进入(其它变种gdb也一样,如arm-none-eabi-gdb-tui),当然也可以进入gdb界面后使用TUI快捷键打开,如C-xC-a快捷键,详见TUI快捷键绑定章节。 1 TUIO...

dataowner的专栏 1317

VoiceAgeG729.rar

VoiceAge公司封装的G.729A静态库G.729A(G729A)编解码库va_g729a源码

上一篇: autotools使用(自动生成Makefile)
下一篇: Ubuntu下配置QEMU出错:ERROR: glib-2.12 required to compile QEMU
nancygreen
博客等级 码龄22年 45粉丝 1原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值