Re: search upward of cscope.out file

2007-03-29 Thread Gary Johnson
On 2007-03-29, "A.J.Mechelynck" <[EMAIL PROTECTED]> wrote:
> Sergey Khorev wrote:
> > You need to run a script, e.g.
> > if filereadable("cscope.out")
> > cs add cscope.out
> > endif
> >
> > if filereadable("../cscope.out")
> > cs add ../cscope.out
> > endif
> >
> > etc :)
> 
> function GetCscopeFileName()
> let curdir = fnamemodify(getcwd(), ':p')
> while 1
> let f = curdir . (curdir =~ '[\\/]$' ? '' : '/') . 'cscope.out'
> if filereadable(f)
> " found
> return f
> endif
> " try one level up
> let d = fnamemodify(curdir, ':h')
> if d == curdir
> " trying to go past top level: not found
> return ''
> endif
> let curdir = d
> endwhile
> endfunction
> 
> let csfn = GetCscopeFileName()
> if csfn != ''
>   exe 'cs add' csfn
> endif

How about using findfile()?

command -nargs=1 CsAdd call CsAdd("")

function CsAdd(file)
let path = findfile(a:file, ".;")
if path != ''
exe 'cs add' path
else
echo a:file "not found"
endif
endfunction

Usage:
:CsAdd cscope.out

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Mobile Broadband Division
 | Spokane, Washington, USA


Re: search upward of cscope.out file

2007-03-29 Thread A.J.Mechelynck

Sergey Khorev wrote:

You need to run a script, e.g.
if filereadable("cscope.out")
cs add cscope.out
endif

if filereadable("../cscope.out")
cs add ../cscope.out
endif

etc :)


function GetCscopeFileName()
let curdir = fnamemodify(getcwd(), ':p')
while 1
let f = curdir . (curdir =~ '[\\/]$' ? '' : '/') . 'cscope.out'
if filereadable(f)
" found
return f
endif
" try one level up
let d = fnamemodify(curdir, ':h')
if d == curdir
" trying to go past top level: not found
return ''
endif
let curdir = d
endwhile
endfunction

let csfn = GetCscopeFileName()
if csfn != ''
exe 'cs add' csfn
endif



Best regards,
Tony.
--
One promising concept that I came up with right away was that you could
manufacture personal air bags, then get a law passed requiring that
they be installed on congressmen to keep them from taking trips.  Let's
say your congressman was trying to travel to Paris to do a fact-finding
study on how the French government handles diseases transmitted by
sherbet.  Just when he got to the plane, his mandatory air bag,
strapped around his waist, would inflate -- FWWAA -- thus
rendering him too large to fit through the plane door.  It could also
be rigged to inflate whenever the congressman proposed a law.  ("Mr.
Speaker, people ask me, why should October be designated as Cuticle
Inspection Month?  And I answer that FWWAA.") This would save
millions of dollars, so I have no doubt that the public would violently
support a law requiring airbags on congressmen.  The problem is that
your potential market is very small: there are only around 500 members
of Congress, and some of them, such as House Speaker "Tip" O'Neil, are
already too large to fit on normal aircraft.
-- Dave Barry, "'Mister Mediocre' Restaurants"


Re: search upward of cscope.out file

2007-03-29 Thread Sergey Khorev

You need to run a script, e.g.
if filereadable("cscope.out")
cs add cscope.out
endif

if filereadable("../cscope.out")
cs add ../cscope.out
endif

etc :)


Winfred Lu wrote:

Hi all,

Is there any way to configure .vimrc
telling vim to search cscope.out file upward
for the command: "cs add cscope.out"?

Take ctags as an example,
if writing "set tags=tags;",
vim will search "tags" at current directory and all parent directories.

It doesn't work to use "cs add cscope.out;"

Best Regards,
Winfred





search upward of cscope.out file

2007-03-28 Thread Winfred Lu

Hi all,

Is there any way to configure .vimrc
telling vim to search cscope.out file upward
for the command: "cs add cscope.out"?

Take ctags as an example,
if writing "set tags=tags;",
vim will search "tags" at current directory and all parent directories.

It doesn't work to use "cs add cscope.out;"

Best Regards,
Winfred