Skip to content

Commit 1aae392

Browse files
committed
Don't try to use dynamic tags files for non-writable directories (issue #29)
This fixes the problem described here: #29
1 parent c455d6e commit 1aae392

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ By default `:UpdateTags` only writes to the global tags file, but it can be conf
9191

9292
You can change the name of the tags file, the important thing is that it's relative to your working directory or the buffer (using a leading `./`). When `g:easytags_dynamic_files` is set to 1 the easytags plug-in will write to the first existing tags file seen by Vim (based on the ['tags' option] [tags_opt]). In other words: If a project specific tags file is found it will be used, otherwise the plug-in falls back to the global tags file (or a file type specific tags file).
9393

94-
If you set `g:easytags_dynamic_files` to 2 the easytags plug-in will automatically create project specific tags based on the first name in the 'tags' option. This disables the global tags file and file type specific tags files.
94+
If you set `g:easytags_dynamic_files` to 2 the easytags plug-in will automatically create project specific tags based on the first name in the 'tags' option. In this mode the the global tags file or file type specific tags files are only used for directories where you don't have write permissions.
9595

9696
The ['tags' option] [tags_opt] is reevaluated each time the plug-in runs, so which tags file is selected can differ depending on the buffer and working directory.
9797

autoload/xolox/easytags.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: April 30, 2013
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '3.1.7'
6+
let g:xolox#easytags#version = '3.1.8'
77

88
call xolox#misc#compat#check('easytags', 2)
99

@@ -651,6 +651,13 @@ function! xolox#easytags#get_tagsfile() " {{{2
651651
let tagsfile = get(tagfiles(), 0, '')
652652
elseif dynamic_files == 2
653653
let tagsfile = xolox#misc#option#eval_tags(&tags, 1)
654+
let directory = fnamemodify(tagsfile, ':h')
655+
if filewritable(directory) != 2
656+
" If the directory of the dynamic tags file is not writable, we fall
657+
" back to a file type specific tags file or the global tags file.
658+
call xolox#misc#msg#warn("easytags.vim %s: Dynamic tags files enabled but %s not writable so falling back.", g:xolox#easytags#version, directory)
659+
let tagsfile = ''
660+
endif
654661
endif
655662
" Check if a file type specific tags file is useful?
656663
if empty(tagsfile) && !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0

doc/easytags.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ file).
229229

230230
If you set |g:easytags_dynamic_files| to 2 the easytags plug-in will
231231
automatically create project specific tags based on the first name in the
232-
'tags' option. This disables the global tags file and file type specific tags
233-
files.
232+
'tags' option. In this mode the the global tags file or file type specific
233+
tags files are only used for directories where you don't have write
234+
permissions.
234235

235236
The |'tags'| option is reevaluated each time the plug-in runs, so which tags
236237
file is selected can differ depending on the buffer and working directory.

0 commit comments

Comments
 (0)