etags - Build a TAG for Multiple R Packages
04 May 2016Here is what tried to build a TAG for multiple R packages. It enable me to jump to a location where the function/variable is defined and modify if I want to.
Useful variable and functions
- ess-r-package-library-path
- default path to find packages, should be a list
- ess-r-package-root-file
- if the folder has DESCRIPTION file, then the folder is a R package.
- (ess-build-tags-for-directory DIR TAGFILE)
- build tag on DIR to TARGET.
- tags-table-list
- List of file names of tags tables to search.
- (visit-tags-table FILE &optional LOCAL)
- Tell tags commands to use tags table file.
Note the workhorse is ess-build-tags-for-directory
which does what
it means. The core of this function use find
and etags
program.
The find
program will find files with extension .cpp, R, nw etc, and
then feed to (using pipe) to the etags
program which generate a TAG
table. These two steps are demonstrated in the following snippet,
which is grabbed from the source code of
ess-build-tags-for-directory
.
Note when they are used in Emacs, the tags-table-list variable is
appended with the path to the new TAG table. So that the user can use
xref-find-definitions
(M-.
) to jump (if the point is under a word) or
select which function/variable to jump to. The users then check the
function/variable definition, or modify it if it is necessary. Then
call xref-pop-marker-stack
(M-,
) to jump back.