Emacs中使用etags [2]

Install ecb : 

 

Step 1] sudo apt-get install ecb

 

Step 2] Download xcscopel.el in ~/bin folder and set this file path in .emacs file :

 

http://opensource.apple.com/source/cscope/cscope-5/cscope/contrib/xcscope/xcscope.el

 

Step 3] Download : http://deep.syminet.com/.emacs

 

Step 4] add below lines on to your .emacs file.

 

(require 'xcscope)
(setq load-path (cons "~/bin" load-path))

 

Symbol Lookup : 

 

Step 1] Go to Project

 

2] run etags command given below on top directory of Project :
find . -name ‘*.c’ -exec etags -a {} \;  -u To Update TAGS table instead -a
or
Assuming CODEDIR to be the top-level source directory, first update your ~/.bashrc like so:

 

alias mktags=’cd $CODEDIR && etags `find $CODEDIR -name “*.[h|c]“` && cd -’

 

Then run:
source ~/.bashrc
mktags

 

Command to Load TAGS in emacs : ALT-M visit-tag-table [It will ask path gives the Path]

 

3] Load etags in emacs : M-x tag-visible-table [give you TAGS path here]

 

Emacs etags Command :

 

Using etags with emacs
1. First tag the entire code. Go to the first directory and run

 

$ etags `find . -name “*.c” -o -name “*.cpp” -o -name “*.h”`

 

This is if you are looking for C\CPP\H files. This will generate a “TAGS” file.

 

2. Open emacs and go to your code directory

 

3. Let emacs know about the tag file

 

M-x visit-tag-table [location of the TAGS file]

 

4. Select the function and do the following

 

M-. (which translates to ALT-.)

 

This would take you to the function anywhere in the entire directory structure

 

5. To go back use

 

M-*, which translates to ALT-SHIFT-*

 

Symbol Lookup with cscope

 

Download cscope program, and xcscope.el and cscope-indexer from some place. Save the xcscope.el onto some directory in Emacs’ load-path. Edit your ~/.emacs as follows:

 

(require 'xcscope)

 

To add a directory ~/foo to your load-path, use the following directive in .emacs file, making sure it appears before the “require xcscope” directive:

 

(setq load-path (cons "~/foo" load-path))

 

Place cscope-indexer in your $PATH. You can then use these keystrokes while browsing C source code:

 

  • Index files: C-c s I
  • Find global definition: C-c s d
  • Find symbol definition: C-c s s
  • Find this file: C-c s f
  • Find functions calling this function: C-c s c
  • Find functions called by this function: C-c s C
  • Find this pattern: C-c s e
  • Find this text string: C-c s t
  • Find files including this file: C-c s i

 

 Emacs Dired Command :
C-x d, producing output similar to Bash ‘ls -l’
C-x d — start dired mode
M-x dired — start dired mode

 

Once dired mode starts the following keys effect the actions. Notice character input is upper case not lower.

 

d — Delete
o — open file in other window
v — view file

C — Copy
G — Change group
M — Chmod
O — Chown
P — Print
U — Undo
X — Shell command
Z — Compress
C-g — Cancel action

posted on 2012-04-20 16:15  Richard.FreeBSD  阅读(332)  评论(0编辑  收藏  举报

导航