[PATCH] Add an option for vim to use directory of cscope.out as prefix path

70 views
Skip to first unread message

Raghavendra D Prabhu

unread,
Apr 16, 2011, 8:03:01 AM4/16/11
to vim...@googlegroups.com
Hi,
Currently when using cscope with vim and being several levels deep from
project root directory (with cscope.out located in this directory), the
cscope queries fail because of lack of prefix. Using a cscope prefix on
a per-project basis is hard. So, this patch introduces a boolean
variable setting which vim will be able use (in the absence of an
already existing prefix path) the prefix of cscope.out to canonicalize
the path obtained from 'cs find'. I have also tested it and it works
fine.

--------------------------
Raghavendra Prabhu
GPG Id : D72BE977
Fingerprint: B93F EBCB 8E05 7039 CD3C A4B8 A616 DCA1 D72B E977

0001-Added-cscopeoutppath-csop.patch
0002-Updated-documentation-for-cscopeoutppath.patch

Bram Moolenaar

unread,
Apr 17, 2011, 5:26:25 PM4/17/11
to Raghavendra D Prabhu, vim...@googlegroups.com

Raghavendra D Prabhu wrote:

> Currently when using cscope with vim and being several levels deep from
> project root directory (with cscope.out located in this directory), the
> cscope queries fail because of lack of prefix. Using a cscope prefix on
> a per-project basis is hard. So, this patch introduces a boolean
> variable setting which vim will be able use (in the absence of an
> already existing prefix path) the prefix of cscope.out to canonicalize
> the path obtained from 'cs find'. I have also tested it and it works
> fine.

Isn't this similar to what 'tagrelative' does to file names in tags
files? Then perhaps we should use a similar name: 'cscoperelative'?

--
hundred-and-one symptoms of being an internet addict:
17. You turn on your intercom when leaving the room so you can hear if new
e-mail arrives.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Raghavendra D Prabhu

unread,
Apr 18, 2011, 2:23:56 AM4/18/11
to Bram Moolenaar, vim...@googlegroups.com
* On Sun, Apr 17, 2011 at 11:26:25PM +0200, Bram Moolenaar <Br...@Moolenaar.net> wrote:
>
>Raghavendra D Prabhu wrote:
>
>> Currently when using cscope with vim and being several levels deep from
>> project root directory (with cscope.out located in this directory), the
>> cscope queries fail because of lack of prefix. Using a cscope prefix on
>> a per-project basis is hard. So, this patch introduces a boolean
>> variable setting which vim will be able use (in the absence of an
>> already existing prefix path) the prefix of cscope.out to canonicalize
>> the path obtained from 'cs find'. I have also tested it and it works
>> fine.
>
>Isn't this similar to what 'tagrelative' does to file names in tags
>files? Then perhaps we should use a similar name: 'cscoperelative'?
Yeah, 'cscoperelative' name makes more sense and it will be easier for
people to find it too. I have attached patch with the name change.
0001-Added-cscoperelative-csre.patch
0002-Updated-documentation-for-cscoperelative.patch

Bram Moolenaar

unread,
May 19, 2011, 9:20:44 AM5/19/11
to Raghavendra D Prabhu, vim...@googlegroups.com

Raghavendra D Prabhu wrote:

A few remarks about the patch. Please fix this and send a new patch.

The strdup() calls are leaking memory. You can't use dirname(), it's
not on all systems.

I don't think it works when the directory name is empty, it would result
in a leading slash.

You can use gettail(). You probably want to compute the size of the
directory name and concate the name when it's not zero. Search for
"p_tr" in src/tag.c for an example. The use of vim_isAbsName() might
also apply.

Please use coding style as in the rest of the Vim sources.

The documentation in if_cscop.txt isn't very clear. Please mention what
happens to a path that cscope returns. I don't know what "prefix path"
means. Either explain that or use some other wording.

--
From "know your smileys":
% Bike accident. A bit far-fetched, I suppose; although...
o _ _ _
_o /\_ _ \\o (_)\__/o (_)
_< \_ _>(_) (_)/<_ \_| \ _|/' \/
(_)>(_) (_) (_) (_) (_)' _\o_

Raghavendra D Prabhu

unread,
May 19, 2011, 4:16:06 PM5/19/11
to Bram Moolenaar, vim...@googlegroups.com

Hi,
Thanks for all the comments. I have made appropriate changes. I have
attached the patch. I have also improved the documentation.
Suggestions welcome.

Regards,
--------------------------
Raghavendra Prabhu
GPG Id : 0xD72BE977


Fingerprint: B93F EBCB 8E05 7039 CD3C A4B8 A616 DCA1 D72B E977

www: wnohang.net

0001-FEATURE-Add-cscoperelative.patch

Bram Moolenaar

unread,
May 20, 2011, 2:21:07 PM5/20/11
to Raghavendra D Prabhu, vim...@googlegroups.com

Raghavendra D Prabhu wrote:

Thanks for the quick response. I'll look at it next week.

--
I AM THANKFUL...
...for all the complaining I hear about the government
because it means we have freedom of speech.

Reply all
Reply to author
Forward
0 new messages