Skip to content

Commit

Permalink
Don't try to use dynamic tags files for non-writable directories (issue
Browse files Browse the repository at this point in the history
#29)

This fixes the problem described here:
#29
  • Loading branch information
xolox committed Apr 30, 2013
1 parent c455d6e commit 1aae392
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -91,7 +91,7 @@ By default `:UpdateTags` only writes to the global tags file, but it can be conf


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). 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).


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. 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.


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. 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.


Expand Down
9 changes: 8 additions & 1 deletion autoload/xolox/easytags.vim
Expand Up @@ -3,7 +3,7 @@
" Last Change: April 30, 2013 " Last Change: April 30, 2013
" URL: http://peterodding.com/code/vim/easytags/ " URL: http://peterodding.com/code/vim/easytags/


let g:xolox#easytags#version = '3.1.7' let g:xolox#easytags#version = '3.1.8'


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


Expand Down Expand Up @@ -651,6 +651,13 @@ function! xolox#easytags#get_tagsfile() " {{{2
let tagsfile = get(tagfiles(), 0, '') let tagsfile = get(tagfiles(), 0, '')
elseif dynamic_files == 2 elseif dynamic_files == 2
let tagsfile = xolox#misc#option#eval_tags(&tags, 1) let tagsfile = xolox#misc#option#eval_tags(&tags, 1)
let directory = fnamemodify(tagsfile, ':h')
if filewritable(directory) != 2
" If the directory of the dynamic tags file is not writable, we fall
" back to a file type specific tags file or the global tags file.
call xolox#misc#msg#warn("easytags.vim %s: Dynamic tags files enabled but %s not writable so falling back.", g:xolox#easytags#version, directory)
let tagsfile = ''
endif
endif endif
" Check if a file type specific tags file is useful? " Check if a file type specific tags file is useful?
if empty(tagsfile) && !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0 if empty(tagsfile) && !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
Expand Down
5 changes: 3 additions & 2 deletions doc/easytags.txt
Expand Up @@ -229,8 +229,9 @@ file).


If you set |g:easytags_dynamic_files| to 2 the easytags plug-in will 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 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 'tags' option. In this mode the the global tags file or file type specific
files. tags files are only used for directories where you don't have write
permissions.


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

0 comments on commit 1aae392

Please sign in to comment.