last one"
< For a ":djump", ":dsplit", ":dlist" and ":dsearch" command the pattern
is used as a literal string, not as a search pattern.
==============================================================================
7. Using 'tagfunc' *tag-function*
It is possible to provide Vim with a function which will generate a list of
tags used for commands like |:tag|, |:tselect|, Normal mode tag commands like
|CTRL-]| and for the |taglist()| function.
The function used for generating the taglist is specified by setting the
'tagfunc' option. The function will be called with three arguments:
pattern The tag identifier or pattern used during the tag search.
flags String containing flags to control the function behavior.
info Dict containing the following entries:
buf_ffname Full filename which can be used for priority.
user_data Custom data String, if stored in the tag
stack previously by tagfunc.
Note that "a:" needs to be prepended to the argument name when using it.
Currently up to three flags may be passed to the tag function:
'c' The function was invoked by a normal command being processed
(mnemonic: the tag function may use the context around the
cursor to perform a better job of generating the tag list.)
'i' In Insert mode, the user was completing a tag (with
|i_CTRL-X_CTRL-]| or 'complete' contains "`t`" or "`]`").
'r' The first argument to tagfunc should be interpreted as a
|pattern| (see |tag-regexp|), such as when using: >
:tag /pat
< It is also given when completing in insert mode.
If this flag is not present, the argument is usually taken
literally as the full tag name.
Note that when 'tagfunc' is set, the priority of the tags described in
|tag-priority| does not apply. Instead, the priority is exactly as the
ordering of the elements in the list returned by the function.
*E987*
The function should return a List of Dict entries. Each Dict must at least
include the following entries and each value must be a string:
name Name of the tag.
filename Name of the file where the tag is defined. It is
either relative to the current directory or a full path.
cmd Ex command used to locate the tag in the file. This
can be either an Ex search pattern or a line number.
Note that the format is similar to that of |taglist()|, which makes it possible
to use its output to generate the result.
The following fields are optional:
kind Type of the tag.
user_data String of custom data stored in the tag stack which
can be used to disambiguate tags between operations.
If the function returns |v:null| instead of a List, a standard tag lookup will
be performed instead.
It is not allowed to change the tagstack from inside 'tagfunc'. *E986*
It is not allowed to close a window or change window from inside 'tagfunc'.
*E1299*
The following is a hypothetical example of a function used for 'tagfunc'. It
uses the output of |taglist()| to generate the result: a list of tags in the
inverse order of file names.
>vim
function CompareFilenames(item1, item2)
let f1 = a:item1['filename']
let f2 = a:item2['filename']
return f1 >=# f2 ? -1 : f1 <=# f2 ? 1 : 0
endfunction
function TagFunc(pattern, flags, info)
let result = taglist(a:pattern)
call sort(result, "CompareFilenames")
return result
endfunc
set tagfunc=TagFunc
<
Note: When executing |taglist()| the 'tagfunc' function won't be called
recursively.
vim:tw=78:ts=8:noet:ft=help:norl: