# HG changeset patch # User Ludovic Chabant # Date 1487207700 28800 # Node ID bba76de4371a45658e0e095e337d375b35249f32 # Parent 6b00f4383708eb3f0db8b8cd4a3a850521711757 Add option to specify that a custom file lister returns absolute paths. diff -r 6b00f4383708 -r bba76de4371a autoload/gutentags/ctags.vim --- a/autoload/gutentags/ctags.vim Wed Feb 15 17:14:12 2017 -0800 +++ b/autoload/gutentags/ctags.vim Wed Feb 15 17:15:00 2017 -0800 @@ -39,6 +39,8 @@ " Get to the tags file directory because ctags is finicky about " these things. let l:prev_cwd = getcwd() + execute "chdir " . fnameescape(a:proj_dir) + let l:tags_file_exists = filereadable(a:tags_file) if l:tags_file_exists && g:gutentags_ctags_check_tagfile @@ -54,14 +56,13 @@ if empty(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. + " as specified by the user, since it's relative to the project root, + " and we are already `chdir`'d into it. " 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. @@ -84,6 +85,14 @@ else let l:file_list_cmd = gutentags#get_project_file_list_cmd(l:actual_proj_dir) if !empty(l:file_list_cmd) + let l:suffopts = matchstrpos(l:file_list_cmd, '///') + if l:suffopts[1] > 0 + let l:suffoptstr = strpart(l:file_list_cmd, l:suffopts[2]) + let l:file_list_cmd = strpart(l:file_list_cmd, 0, l:suffopts[1]) + if l:suffoptstr == 'absolute' + let l:cmd .= ' -A' + endif + endif let l:cmd .= ' -L ' . '"' . l:file_list_cmd. '"' endif endif diff -r 6b00f4383708 -r bba76de4371a plat/unix/update_tags.sh --- a/plat/unix/update_tags.sh Wed Feb 15 17:14:12 2017 -0800 +++ b/plat/unix/update_tags.sh Wed Feb 15 17:15:00 2017 -0800 @@ -8,6 +8,7 @@ TAGS_FILE=tags PROJECT_ROOT= FILE_LIST_CMD= +FILE_LIST_CMD_IS_ABSOLUTE=0 UPDATED_SOURCE= PAUSE_BEFORE_EXIT=0 @@ -20,6 +21,8 @@ echo " -t [file=tags]: The path to the ctags file to update" echo " -p [dir=]: The path to the project root" echo " -L [cmd=]: The file list command to run" + echo " -A: Specifies that the file list command returns " + echo " absolute paths" echo " -s [file=]: The path to the source file that needs updating" echo " -x [pattern=]: A pattern of files to exclude" echo " -o [options=]: An options file to read additional options from" @@ -28,7 +31,7 @@ } -while getopts "h?e:x:t:p:L:s:o:c" opt; do +while getopts "h?e:x:t:p:L:s:o:cA" opt; do case $opt in h|\?) ShowUsage @@ -49,6 +52,9 @@ L) FILE_LIST_CMD=$OPTARG ;; + A) + FILE_LIST_CMD_IS_ABSOLUTE=1 + ;; s) UPDATED_SOURCE=$OPTARG ;; @@ -88,7 +94,7 @@ if [ $INDEX_WHOLE_PROJECT -eq 1 ]; then if [ -n "${FILE_LIST_CMD}" ]; then - if [ "${PROJECT_ROOT}" = "." ]; then + if [ "${PROJECT_ROOT}" = "." ] || [ $FILE_LIST_CMD_IS_ABSOLUTE -eq 1 ]; then $FILE_LIST_CMD > "${TAGS_FILE}.files" else # If using a tags cache directory, use absolute paths diff -r 6b00f4383708 -r bba76de4371a plat/win32/update_tags.cmd --- a/plat/win32/update_tags.cmd Wed Feb 15 17:14:12 2017 -0800 +++ b/plat/win32/update_tags.cmd Wed Feb 15 17:15:00 2017 -0800 @@ -10,6 +10,7 @@ set TAGS_FILE=tags set PROJECT_ROOT= set FILE_LIST_CMD= +set FILE_LIST_CMD_IS_ABSOLUTE=0 set UPDATED_SOURCE= set PAUSE_BEFORE_EXIT=0 set LOG_FILE= @@ -41,6 +42,10 @@ shift goto :LoopParseArgs ) +if [%1]==[-A] ( + set FILE_LIST_CMD_IS_ABSOLUTE=1 + goto :LoopParseArgs +) if [%1]==[-s] ( set UPDATED_SOURCE=%~2 shift @@ -93,7 +98,12 @@ set CTAGS_ARGS=%CTAGS_ARGS% "%PROJECT_ROOT%" if not ["%FILE_LIST_CMD%"]==[""] ( echo Running custom file lister >> %LOG_FILE% - if ["%PROJECT_ROOT%"]==["."] ( + echo Licensee is %LICENSEE_ID% >> %LOG_FILE% + set use_raw_list=0 + if ["%PROJECT_ROOT%"]==["."] set use_raw_list=1 + if ["%FILE_LIST_CMD_IS_ABSOLUTE%"]==["1"] set use_raw_list=1 + rem No idea why we need to use delayed expansion here to make it work :( + if ["!use_raw_list!"]==["1"] ( echo call %FILE_LIST_CMD% ^> %TAGS_FILE%.files >> %LOG_FILE% call %FILE_LIST_CMD% > %TAGS_FILE%.files ) else ( @@ -150,6 +160,8 @@ echo -t [file=tags]: The path to the ctags file to update echo -p [dir=]: The path to the project root echo -L [cmd=]: The file list command to run +echo -A: Specifies that the file list command returns +echo absolute paths echo -s [file=]: The path to the source file that needs updating echo -l [log=]: The log file to output to echo -o [options=]: An options file to read additional options from