# HG changeset patch # User Ludovic Chabant # Date 1456463086 28800 # Node ID d645125192aadda58334ccf064004c234499a582 # Parent 794ee111bce6f72d8c3c2dde7e5a0438e21f0d4c Fix more problems with paths and spaces in them. diff -r 794ee111bce6 -r d645125192aa autoload/gutentags.vim --- a/autoload/gutentags.vim Sun Feb 21 10:34:47 2016 -0800 +++ b/autoload/gutentags.vim Thu Feb 25 21:04:46 2016 -0800 @@ -121,7 +121,7 @@ " Put the tag file in the cache dir instead of inside the " projet root. let l:tag_path = g:gutentags_cache_dir . '/' . - \tr(l:tag_path, '\/:', '---') + \tr(l:tag_path, '\/: ', '---_') let l:tag_path = substitute(l:tag_path, '/\-', '/', '') endif let l:tag_path = gutentags#normalizepath(l:tag_path) diff -r 794ee111bce6 -r d645125192aa autoload/gutentags/ctags.vim --- a/autoload/gutentags/ctags.vim Sun Feb 21 10:34:47 2016 -0800 +++ b/autoload/gutentags/ctags.vim Thu Feb 25 21:04:46 2016 -0800 @@ -22,10 +22,6 @@ let g:gutentags_ctags_check_tagfile = 0 endif -if !exists('g:gutentags_ctags_no_space_in_paths') - let g:gutentags_ctags_no_space_in_paths = 1 -endif - " }}} " Gutentags Module Interface {{{ @@ -34,15 +30,8 @@ function! gutentags#ctags#init(project_root) abort " Figure out the path to the tags file. - if g:gutentags_ctags_no_space_in_paths - " We need to replace spaces in the project root because `ctags` seems - " incapable of reading/writing to tags files with spaces. - let l:fixed_project_root = tr(a:project_root, ' ', '_') - else - let l:fixed_project_root = a:project_root - endif let b:gutentags_files['ctags'] = gutentags#get_cachefile( - \l:fixed_project_root, g:gutentags_tagfile) + \a:project_root, g:gutentags_tagfile) " Set the tags file for Vim to use. if g:gutentags_auto_set_tags @@ -62,7 +51,6 @@ " Get to the tags file directory because ctags is finicky about " these things. let l:prev_cwd = getcwd() - let l:work_dir = fnamemodify(a:tags_file, ':h') let l:tags_file_exists = filereadable(a:tags_file) if l:tags_file_exists && g:gutentags_ctags_check_tagfile @@ -75,14 +63,29 @@ endif endif - execute "chdir " . fnameescape(l:work_dir) + if g:gutentags_cache_dir == "" + " If we don't use the cache directory, let's just use the tag filename + " as specified by the user, and change the working directory to the + " project root. + " Note that if we don't do this and pass a full path, `ctags` gets + " confused if the paths have spaces -- but not if you're *in* the + " root directory. + let l:actual_proj_dir = '.' + let l:actual_tags_file = g:gutentags_tagfile + execute "chdir " . fnameescape(a:proj_dir) + else + " else: the tags file goes in a cache directory, so we need to specify + " all the paths absolutely for `ctags` to do its job correctly. + let l:actual_proj_dir = a:proj_dir + let l:actual_tags_file = a:tags_file + endif try " Build the command line. let l:cmd = gutentags#get_execute_cmd() . s:runner_exe let l:cmd .= ' -e "' . s:get_ctags_executable(a:proj_dir) . '"' - let l:cmd .= ' -t "' . a:tags_file . '"' - let l:cmd .= ' -p "' . a:proj_dir . '"' + let l:cmd .= ' -t "' . l:actual_tags_file . '"' + let l:cmd .= ' -p "' . l:actual_proj_dir . '"' if a:write_mode == 0 && l:tags_file_exists let l:full_path = expand('%:p') let l:cmd .= ' -s "' . l:full_path . '"' @@ -108,9 +111,9 @@ endif if g:gutentags_trace if has('win32') - let l:cmd .= ' -l "' . a:tags_file . '.log"' + let l:cmd .= ' -l "' . l:actual_tags_file . '.log"' else - let l:cmd .= ' > "' . a:tags_file . '.log" 2>&1' + let l:cmd .= ' > "' . l:actual_tags_file . '.log" 2>&1' endif else if !has('win32') diff -r 794ee111bce6 -r d645125192aa doc/gutentags.txt --- a/doc/gutentags.txt Sun Feb 21 10:34:47 2016 -0800 +++ b/doc/gutentags.txt Thu Feb 25 21:04:46 2016 -0800 @@ -378,16 +378,6 @@ See |gutentags_ctags_executable_{filetype}| for more information. - *gutentags_ctags_no_space_in_paths* -g:gutentags_ctags_no_space_in_paths - When set to 1, the root path of a project will have - any spaces replaced by underscores. This is in case - the particular `ctags` implementation you're using - doesn't support tags filenames with spaces, which - seems to be the case with Exuberant Ctags. - Set to 0 to leave project root paths as is. - Defaults to 1. - ============================================================================= 5. Project Settings *gutentags-project-settings*