Chinaunix首页 | 论坛 | 博客
  • 博客访问: 17277
  • 博文数量: 7
  • 博客积分: 422
  • 博客等级: 下士
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-22 16:38
文章分类
文章存档

2009年(3)

2008年(4)

我的朋友

分类: LINUX

2009-05-29 00:01:41

在emacs里可以用etags命令生成emacs专用的tags文件,有了此文件之后便可以使用一些emacs tags的命令,比如对于编辑C/C++程序的人员可以方便的定位一个函数的定义,或者

对函数名进行自动补齐:   


find -name "*.[ch]" -exec etags -a {} \;



#!/bin/sh

trap "rm -f /tmp/$$" 0 1 2 3 15

rm -f ./TAGS

find `pwd`/ -type f -name "*.[chyl]" -print | \
xargs etags --append -o TAGS

find . -type d -print | \
while read DIR; do
  [ "$DIR" != "." ] && ln -f -s `pwd`/TAGS $DIR
done



#!/usr/bin/env python

#使用方法 比如要生成一个TAGS文件包括当前目录下的include和src目录以及子目录下所有的.c .h文件

#命令行: python ezetags -d./include:./src -e.h,.c


import sys
from os import path
from getopt import *
from popen2 import *
def usage():
        sys.stdout.write("usage: ezetags <-dpath2:path2...> <-e.ext1,.ext2....>\n")

def parse_opt():
        opts,args = getopt(sys.argv[1:], "hd:e:", ["help"])
        dlist = None
        elist = None
        for f,v in opts:
                if f in ("-h", "--help"):
                        usage()
                        sys.exit()
                if f=="-e":
                        elist = v.split(',')
                if f=="-d":
                        dlist = v.split(':')
        return dlist,elist

def visit(arg, dirname, names):
        for n in names:
                nm,e = path.splitext(n)
                if e in arg[1]:
                        p = path.join(dirname,n)
                        p+="\n"
                        arg[0].write(p)
                        sys.stdout.write(p)

def main():
        dlist,elist = parse_opt()
        if dlist==None or elist==None:
                usage()
                sys.exit()
        sys.stdout.write("dlist="+str(dlist)+" elist="+str(elist)+"\n")
        fout,fin = popen2("etags -")
        for d in dlist:
                path.walk(d, visit, (fin,elist))
        sys.stdout.write("Done.\n")
        sys.exit()
if __name__ == "__main__":main()


cscope

C-c s A cscope-unset-initial-directory
C-c s B cscope-display-buffer-toggle
C-c s C cscope-find-called-functions
C-c s D cscope-dired-directory
C-c s E cscope-edit-list-of-files-to-index
C-c s G cscope-find-global-definition-no-prompting
C-c s I cscope-index-files
C-c s L cscope-create-list-of-files-to-index
C-c s N cscope-next-file
C-c s P cscope-prev-file
C-c s W cscope-tell-user-about-directory
C-c s a cscope-set-initial-directory
C-c s b cscope-display-buffer
C-c s c cscope-find-functions-calling-this-function
C-c s d cscope-find-global-definition //找所有定义symbol以及用的地方
C-c s e cscope-find-egrep-pattern
C-c s f cscope-find-this-file
C-c s g cscope-find-global-definition //找所有定义symbol
C-c s i cscope-find-files-including-file
C-c s n cscope-next-symbol
C-c s p cscope-prev-symbol
C-c s s cscope-find-this-symbol
C-c s t cscope-find-this-text-string
C-c s u cscope-pop-mark

C-c s S .. C-c s T cscope-tell-user-about-directory

阅读(555) | 评论(0) | 转发(0) |
0

上一篇:(转载)sscanf用法举例

下一篇:链接

给主人留下些什么吧!~~