免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1492 | 回复: 0
打印 上一主题 下一主题

(收集)emacs下使用etags [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-29 00:01 |只看该作者 |倒序浏览

                                在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  \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
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/57669/showart_1947020.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP