Skip to content

Commit d2a2cb5

Browse files
committed
Make "easytags_dynamic_files" create missing tags files
Suggested by Strahinja Marković in GitHub issue #15: #15
1 parent 2860329 commit d2a2cb5

3 files changed

Lines changed: 23 additions & 27 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ You can enable this option so that the project specific tags files are written i
7272

7373
:let g:easytags_dynamic_files = 1
7474

75-
When you enable this option, the easytags plug-in will use the first filename returned by [tagfiles()] [tagfiles_fun] as the tags file to write. Note that `tagfiles()` is reevaluated every time the plug-in runs.
75+
When you enable this option, the easytags plug-in will expand the ['tags' option] [tags_opt] and use the first filename (whether the file exists or not). The tags option is reevaluated each time the plug-in runs, so the results can differ depending on the location of the current buffer or working directory.
7676

77-
If you've also enabled `g:easytags_by_filetype` the project specific tags file must exist, even if it's empty; otherwise `g:easytags_by_filetype` will take precedence.
77+
Note that this option takes precedence over `g:easytags_by_filetype`.
7878

7979
### The `g:easytags_by_filetype` option
8080

8181
By default all tags are stored in a global tags file. When the tags file grows beyond a certain size Vim will be slowed down by the easytags plug-in because it has to read and process a large number of tags very frequently.
8282

8383
To avoid this problem you can set `g:easytags_by_filetype` to the path of an existing directory. The easytags plug-in will create separate tags files for each file type in the configured directory. These tags files are automatically registered by the easytags plug-in when the file type of a buffer is set.
8484

85-
If you've also enabled `g:easytags_dynamic_files` and the project specific tags file exists, and is writable, it will take precedence. If the project specific tags file doesn't exist you can indicate you want to use project specific tags by creating it.
85+
Note that the `g:easytags_dynamic_files` option takes precedence over this option.
8686

87-
Note that if you already have a global tags file you can create file type specific tags files from the global tags file using the command `:TagsByFileType`.
87+
If you already have a global tags file you can create file type specific tags files from the global tags file using the command `:TagsByFileType`.
8888

8989
### The `g:easytags_always_enabled` option
9090

autoload/xolox/easytags.vim

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: August 27, 2011
3+
" Last Change: August 31, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '2.4.12'
6+
let g:xolox#easytags#version = '2.5'
77

88
" Public interface through (automatic) commands. {{{1
99

@@ -518,20 +518,20 @@ function! s:cache_tagged_files_in(fname, ftime, entries) " {{{3
518518
endfunction
519519

520520
function! xolox#easytags#get_tagsfile() " {{{2
521-
" Look for a writable project specific tags file?
521+
let tagsfile = ''
522+
" Look for a suitable project specific tags file?
522523
if xolox#misc#option#get('easytags_dynamic_files', 0)
523-
let files = tagfiles()
524-
if len(files) > 0 && filewritable(files[0]) == 1
525-
return files[0]
526-
endif
524+
let tagsfile = xolox#misc#option#eval_tags(&tags, 1)
527525
endif
528-
" Default to the global tags file.
529-
let tagsfile = expand(xolox#misc#option#get('easytags_file'))
530526
" Check if a file type specific tags file is useful?
531-
if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
527+
if empty(tagsfile) && !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
532528
let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
533529
let tagsfile = xolox#misc#path#merge(directory, &filetype)
534530
endif
531+
" Default to the global tags file?
532+
if empty(tagsfile)
533+
let tagsfile = expand(xolox#misc#option#get('easytags_file'))
534+
endif
535535
" If the tags file exists, make sure it is writable!
536536
if filereadable(tagsfile) && filewritable(tagsfile) != 1
537537
let message = "The tags file %s isn't writable!"

doc/easytags.txt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,12 @@ instead of the global tags file:
149149
>
150150
:let g:easytags_dynamic_files = 1
151151
152-
When you enable this option, the easytags plug-in will use the first filename
153-
returned by |tagfiles()| as the tags file to write. Note that 'tagfiles()' is
154-
reevaluated every time the plug-in runs.
152+
When you enable this option, the easytags plug-in will expand the |'tags'|
153+
option and use the first filename (whether the file exists or not). The tags
154+
option is reevaluated each time the plug-in runs, so the results can differ
155+
depending on the location of the current buffer or working directory.
155156

156-
If you've also enabled |g:easytags_by_filetype| the project specific tags file
157-
must exist, even if it's empty; otherwise |g:easytags_by_filetype| will take
158-
precedence.
157+
Note that this option takes precedence over |g:easytags_by_filetype|.
159158

160159
-------------------------------------------------------------------------------
161160
The *g:easytags_by_filetype* option
@@ -169,14 +168,11 @@ existing directory. The easytags plug-in will create separate tags files for
169168
each file type in the configured directory. These tags files are automatically
170169
registered by the easytags plug-in when the file type of a buffer is set.
171170

172-
If you've also enabled |g:easytags_dynamic_files| and the project specific
173-
tags file exists, and is writable, it will take precedence. If the project
174-
specific tags file doesn't exist you can indicate you want to use project
175-
specific tags by creating it.
171+
Note that the |g:easytags_dynamic_files| option takes precedence over this
172+
option.
176173

177-
Note that if you already have a global tags file you can create file type
178-
specific tags files from the global tags file using the command
179-
':TagsByFileType'.
174+
If you already have a global tags file you can create file type specific tags
175+
files from the global tags file using the command ':TagsByFileType'.
180176

181177
-------------------------------------------------------------------------------
182178
The *g:easytags_always_enabled* option

0 commit comments

Comments
 (0)