From fe3f565ebdd565f81ea7dd52cd8bdbf843f971fe Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Mon, 26 Sep 2011 02:19:00 +0200 Subject: Search the whole $PATH for Exuberant Ctags (issue #18) --- autoload/xolox/easytags.vim | 2 +- plugin/easytags.vim | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim index a54171e..ab284f2 100644 --- a/autoload/xolox/easytags.vim +++ b/autoload/xolox/easytags.vim @@ -3,7 +3,7 @@ " Last Change: September 26, 2011 " URL: http://peterodding.com/code/vim/easytags/ -let g:xolox#easytags#version = '2.5.9' +let g:xolox#easytags#version = '2.6' " Public interface through (automatic) commands. {{{1 diff --git a/plugin/easytags.vim b/plugin/easytags.vim index acc9fda..d3624a5 100644 --- a/plugin/easytags.vim +++ b/plugin/easytags.vim @@ -1,6 +1,6 @@ " Vim plug-in " Author: Peter Odding -" Last Change: September 4, 2011 +" Last Change: September 26, 2011 " URL: http://peterodding.com/code/vim/easytags/ " Requires: Exuberant Ctags (http://ctags.sf.net) @@ -50,15 +50,39 @@ function! s:InitEasyTags(version) if exists('g:easytags_cmd') && s:CheckCtags(g:easytags_cmd, a:version) return 1 endif - " On Ubuntu Linux, Exuberant Ctags is installed as `ctags'. On Debian Linux, - " Exuberant Ctags is installed as `exuberant-ctags'. On Free-BSD, Exuberant - " Ctags is installed as `exctags'. - for name in ['ctags', 'exuberant-ctags', 'exctags'] - if s:CheckCtags(name, a:version) - let g:easytags_cmd = name + if xolox#misc#os#is_win() + " FIXME The code below that searches the $PATH is not used on Windows at + " the moment because xolox#misc#path#which() generally produces absolute + " paths and on Windows these absolute paths tend to contain spaces which + " makes xolox#shell#execute() fail. I've tried quoting the program name + " with double quotes but it fails just the same (it works with system() + " though). Anyway the problem of having multiple conflicting versions of + " Exuberant Ctags installed is not that relevant to Windows since it + " doesn't have a package management system. I still want to fix + " xolox#shell#execute() though. + if s:CheckCtags('ctags', a:version) + let g:easytags_cmd = 'ctags' return 1 endif - endfor + else + " Exuberant Ctags can be installed under multiple names: + " - On Ubuntu Linux, Exuberant Ctags is installed as `ctags'. + " - On Debian Linux, Exuberant Ctags is installed as `exuberant-ctags'. + " - On Free-BSD, Exuberant Ctags is installed as `exctags'. + " IIUC on Mac OS X the program /usr/bin/ctags is installed by default but + " unusable and when the user installs Exuberant Ctags in an alternative + " location, it doesn't come before /usr/bin/ctags in the search path. To + " solve this problem in a general way and to save every Mac user out there + " some frustration the plug-in will search the path and consider every + " possible location, meaning that as long as Exuberant Ctags is installed + " in the $PATH the plug-in should find it automatically. + for program in xolox#misc#path#which('ctags', 'exuberant-ctags', 'exctags') + if s:CheckCtags(program, a:version) + let g:easytags_cmd = program + return 1 + endif + endfor + endif endfunction function! s:CheckCtags(name, version) -- cgit v1.2.3