6

我正在使用 Exuberant ctags 来索引 Erlang 文件。

“tags”文件包含函数,但它们没有模块限定符;所以我不能搜索“module:function”,只能搜索“function”,这可能会给出几个结果。

你知道让 ctags 在标签文件中包含模块限定符的方法吗?

谢谢。

4

4 回答 4

5

就像 lht 写的那样,Exuberant Ctags 5.8 已经将函数的模块存储在标签文件中。至少在最新版本的 Vim (7.4) 中可以访问此信息。然后可以使用自定义“标签”函数查找“模块:函数”,例如:

function! ErlangTag()
    let isk_orig = &isk
    set isk+=:
    let keyword = expand('<cword>')
    let &isk = isk_orig
    let parts = split(keyword, ':')
    if len(parts) == 1
        execute 'tag' parts[0]
    elseif len(parts) == 2
        let [mod, fun] = parts
        let i = 1
        let fun_taglist = taglist('^' . fun . '$')
        for item in fun_taglist
           if item.kind == 'f' && item.module == mod
               silent execute i . 'tag' fnameescape(item.name)
               break
           endif
           let i += 1
        endfor
    endif
endfunction

nnoremap <buffer> <c-]>    :call ErlangTag()<cr>
于 2013-11-04T22:49:02.200 回答
4

Exuberant ctags 已经支持Erlang 的标签字段“模块”。

$ /usr/bin/ctags --version
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Aug 17 2010, 17:33:33
  Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
  Optional compiled features: +wildcards, +regex
$ /usr/bin/ctags xref_parser.erl

带有名为“module”的标签字段的典型标签行如下所示:

yeccgoto_const  xref_parser.erl /^yeccgoto_const(24=_S, Cat, Ss, Stack, T, Ts, Tzr) ->$/;"      f       module:xref_parser

实际上,VIM 目前还不支持这个标签字段。来自VIM 文档

{field} ..  A list of optional fields.  Each field has the form:

            <Tab>{fieldname}:{value}

        The {fieldname} identifies the field, and can only contain
        alphabetical characters [a-zA-Z].
        The {value} is any string, but cannot contain a <Tab>.

        There is one field that doesn't have a ':'.  This is the kind
        of the tag.  It is handled like it was preceded with "kind:".
        See the documentation of ctags for the kinds it produces.

        The only other field currently recognized by Vim is "file:"
        (with an empty value).  It is used for a static tag.

而已。仅支持“种类”和“文件”的标记字段名称。

于 2010-09-25T15:24:18.770 回答
1

听起来您没有使用 Erlang etags 模块:Generate Emacs TAGS file from Erlang source files

于 2009-09-24T13:18:57.007 回答
0

我是 sublime 2 文本用户,发现 ctags 在我的计算机上正常工作。我ctags plugin用于崇高 2。


->ctags--版本

Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Jul 24 2012, 11:45:55
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
于 2012-07-24T07:15:16.647 回答