Emacs的标签:etags,ebrowse,cscope,GNU Global和旺盛的ctags之间的关系 [英] Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctags

查看:209
本文介绍了Emacs的标签:etags,ebrowse,cscope,GNU Global和旺盛的ctags之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从事C ++项目,并且经历了Alex Ott的 CEDET指南和有关StackOverflow中标记的其他线程,但是我仍然对Emacs如何与这些不同的标记系统进行接口以促进自动完成,查找定义,浏览源代码库或预览文档字符串感到困惑。

I work on C++ projects, and I went through Alex Ott's guide to CEDET and other threads about tags in StackOverflow, but I am still confused about how Emacs interfaces with these different tag systems to facilitate autocompletion, the looking up of definitions, navigation of source code base or the previewing of doc-strings.


  1. etags 之间有什么区别(例如,在功能方面), ebrowse 茂盛的ctags cscope GNU Global GTags ?要在 Emacs 中使用它们,我需要做什么?

  1. What is the difference (e.g. in terms of features) between etags, ebrowse, exuberant ctags, cscope, GNU Global and GTags? What do I need to do to use them in Emacs?

如果我想使用语义/参量(CEDET),是否需要使用标签导航/自动完成符号?

Do I need semantic/senator (CEDET) if I want to use tags to navigate/autocomplete symbols?

语义在这些不同的标记实用程序之上带来了什么?

What does semantic bring to the table on top of these different tag utilities? How does it interface with these tools?


推荐答案

这是一个很好的问题正如我最近在这里阅读的一样,因此我将尝试更详细地说明差异:

That's as a good question as I've recently read here, so I'll try explain the difference in more detail:

要点1:

etags ctags 都生成索引(又名标签/ TAGS)文件源文件中找到的语言对象,使这些项目可以通过文本编辑器或其他实用程序快速轻松地定位。标签表示一个语言对象,为其提供了索引条目(或者,为该对象创建的索引条目)。 ctags生成的标签在元数据方面更丰富,但是Emacs仍然无法解释其他数据,因此您应该将它们视为大致相同( ctags 的主要优势)将是它对更多语言的支持)。标签文件的主要用途是查找类/方法/函数/常量/等声明/定义。

etags and ctags both generate an index (a.k.a. tag/TAGS) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object). The tags generated by ctags are richer in terms of metadata, but Emacs cannot interpret the additional data anyways, so you should consider them more or less the same (the main advantage of ctags would be its support for more languages). The primary use for the tags files is looking up class/method/function/constant/etc declaration/definitions.

cscope 是更强大的野兽(至少就C / C ++和Java而言)。尽管它的工作原理大致相同(生成有用的元数据文件),但它允许您做一些更奇特的事情,例如查找对符号的所有引用,查看在何处调用函数等(您也可以找到定义) 。

cscope is much more powerful beast (at least as far as C/C++ and Java are concerned). While it operates on more or less the same principle (generating a file of useful metadata) it allows you do some fancier things like find all references to a symbol, see where a function is being invoked, etc (you can find definitions as well).

总结一下:

ctags 一个允许您导航到符号声明/定义(有些人将其称为单向查找)。 ctags 是适用于多种语言的通用工具。

ctags one allows you to navigate to symbol declaration/definitions (what some would call a one-way lookup). ctags is a general purpose tool useful for many languages.

另一方面(如项目页面所述) ) cscope 允许您:

On the other hand (as mentioned on the project's page) cscope allows you to:


  • 转到符号的声明

  • 显示对符号的所有引用的可选列表

  • 搜索任何全局定义

  • 由a调用的函数function

  • 调用函数的函数

  • 搜索文本字符串

  • 搜索正则表达式模式

  • 查找文件

  • 查找所有文件,包括文件

  • Go to the declaration of a symbol
  • Show a selectable list of all references to a symbol
  • Search for any global definition
  • Functions called by a function
  • Functions calling a function
  • Search for a text string
  • Search for a regular expression pattern
  • Find a file
  • Find all files including a file

在这一点上,对于任何人来说都不足为奇,当我处理C / C ++项目时,我会大量使用 cscope ,而对 ctags 。与其他语言打交道时,情况显然会逆转。

It should come as no surprise to anyone at this point, that when I deal with C/C++ projects I make heavy use of cscope and care very little about ctags. When dealing with other languages the situation would obviously be reversed.

第2点。

要具有智能的自动补全功能,您需要一个真正的源代码解析器(例如语义),否则您将不知道类型应用程序中的对象(例如)以及可以在它们上调用的方法。您可以根据许多不同的来源进行自动补全,但是要获得最佳结果,最终将需要解析器。语法高亮显示也是如此-当前Emacs主要模式下的语法高亮仅基于正则表达式,并且非常脆弱且容易出错。希望在Emacs 23.2中包含语义(在此之前它曾经是外部软件包),我们将开始看到它的更多用途(例如使用它来分析缓冲区源代码以正确突出显示它)

To have intelligent autocompletion you need a true source code parser (like semantic), otherwise you won't know the types of the objects (for instance) in your applications and the methods that can be invoked on them. You can have an autocompletion based on many different sources, but to get the best results you'll ultimately need a parser. Same goes for syntax highlighting - currently syntax highlighting in Emacs major modes is based simply on regular expressions and that's very fragile and error prone. Hopefully with the inclusion of semantic in Emacs 23.2 (it used to be an external package before that) we'll start seeing more uses for it (like using it to analyse a buffer source code to properly highlight it)

由于Emacs 24.1语义在Emacs完成框架中可用。测试它的最简单方法是打开一个C源代码文件,然后键入 M-TAB C-M-i ,然后为您自动完成语义的监视。对于默认情况下未启用语义的语言,可以将其添加到主模式选择行的以下行:

Since Emacs 24.1 semantic is usable from the Emacs completion framework. The easiest way to test it is to open up a C source code file and typing M-TAB or C-M-i and watch as semantic automagically completes for you. For languages where semantic is not enabled by default, you can add it the following line to your major mode hook of choice:

(add-to-list 'completion-at-point-functions 'semantic-completion-at-point-function)

第3点。

语义带来了真正的代码意识(针对当前支持的几种语言),并缩小了IDE和Emacs之间的差距。它实际上并没有与 etags cscope 之类的工具交互,但这并不意味着您不能将它们一起使用

semantic brings true code awareness (for the few languages it currently supports) and closes the gap between IDEs and Emacs. It doesn't really interface with tools like etags and cscope, but it doesn't mean you cannot use them together.

希望我的解释是有道理的,对您会有所帮助。

Hopefully my explanations make sense and will be useful to you.

P.S。我对 global ebrowse 不太熟悉,但是如果有记忆,我会使用etags。

P.S. I'm not quite familiar with global and ebrowse, but if memory serves me they made use of etags.

这篇关于Emacs的标签:etags,ebrowse,cscope,GNU Global和旺盛的ctags之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆