That's probably true. In most instances, my plugin works absolutely fine as it's expected to take over managing cscope connections entirely (i.e. it handles running cs add and cs kill based on its own internal list). However, it also tries to leave the state as it was if the user has MANUALLY added cscope connections and I quickly realised that this didn't work in certain situations because doing something like this fails:
cd c:/path/to/firstlocation
cs add cscope.out
cd c:/path/to/somewhereelse
" Now the plugin wants to pause stuff
cs kill -1
" This fails as it had no way of getting the original path to cscope.out
cs add cscope.out
Quite possible: I only tested this on Windows. Unfortunately, since there's no function-type interface to cscope, there's no way of getting the database path from the above.
> However, if I then execute ":cs reset", ":cs show" shows only one
> entry:
>
> # pid database name prepend path
> 0 28563 cscope.out <none>
That certainly looks wrong.
> It seems to me that Vim ought to resolve and display the cscope
> database files used for cscope connections in the same way it does
> for files being edited. That is, a cscope.out file in the current
> directory would be displayed as "cscope.out" and one in a different
> directory would be displayed as "/path/to/dir/cscope.out". That
> display could change as the current directory changes.
Yes.
> A ":cs reset" would then use a valid path to the database file of
> each connection being reset, rather than just using the file name
> that each connection was started with.
>
> A ":cs show" would also then provide more useful information about
> the file used for each database and might be used as described in
> the first paragraph of the bug report. However, the full path name
> to a database file may not fit in the space allowed in the ":cs
> show" output. Long names should be shorted as is done for the
> ":file" command. Trying to determine the file name by scraping the
> output of ":cs show" would be like trying to determine the name of
> the current file by scraping the output of ":file" and would
> generally not be successful.
Yes, a function interface to allow the details to be retrieved would be really nice.
> While Vim could provide a list variable or a function for accessing
> the list of cscope connection files, I think it would be acceptable
> to require a plugin to manage this list itself.
Yes, I do this already (as I said above), unfortunately this doesn't help with manually started cscope connections.
Al
Yes!
> I think this patch does it:
>
> iff --git a/src/if_cscope.c b/src/if_cscope.c
> --- a/src/if_cscope.c
> +++ b/src/if_cscope.c
> @@ -539,12 +539,17 @@
> char *fname2 = NULL;
> char *ppath = NULL;
> int i;
> + int len;
> + int usedlen = 0;
> + char_u *fbuf = NULL;
>
> /* get the filename (arg1), expand it, and try to stat it */
> if ((fname = (char *)alloc(MAXPATHL + 1)) == NULL)
> goto add_err;
>
> expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
> + len = (int)STRLEN(fname);
> + (void)modify_fname((char_u *)":p", &usedlen, (char_u **) &fname, &fbuf, &len);
> ret = stat(fname, &statbuf);
> if (ret < 0)
> {
>
>
> regards,
> Christian
Certainly looks promising: what do you think are the chances of getting this into Vim 7.4? As discussed in my other email in this thread, there are sadly other problems for my plugin with this (the fact that cs show won't be able to display long file-names), but this would certainly be a massive improvement on where we are now. Ideally, it would be good to have a function() interface to "cs show" to get the details programmatically, but I'd guess that's quite a lot more work for relatively little benefit.
Thanks for the patch.
Al