Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when >> 1 tag exists, can the order in which they are offered be controlled? #99

Closed
gthaker opened this issue May 19, 2015 · 19 comments
Closed

Comments

@gthaker
Copy link

gthaker commented May 19, 2015

Hi:

I am new to ggtags but it is very nice. I am using it to work on a large system in which there are many many directories (with subdirectories) that each contain one test program. Each of this test program has a function named "Initialize_System()". When I do a "M-." sure enough all 54 choices are offered that I can go thru with M-n/p, but it would be great if the first choice offered would be from a file that is "closest" to where I am doing a M-. By closest I mean:

First match offer should be if that function exists in a file in this directory.
Then 2nd match offer would be if that function is defined in any of the subdirectories of where M-. is done.
Then move up one directory and see if function exists there or in any subdirectory at that level.
Then move up one more directory and repeat the process.

This way I can find definitions that I want to change most quickly. Presumably M-] would also benefit from such "smarts" (which can be controlled by some config setting variable.) I have things like D1/54 and R1/137, sure could use a way to nagivate more quickly.

Thanks again for a great mode.

@leoliu
Copy link
Owner

leoliu commented May 20, 2015

Hi @gthaker,

See also issue #70.

In short it is difficult to order matches from global. So when choosing a match M-= will jump to matches from the start file if any.

Leo

@gthaker
Copy link
Author

gthaker commented May 24, 2015

OK, I understand better. How about one small possibility: global with '-l' option finds only entries that are in this directory (and below). This is a powerful way to localize the search and limit the very long lists that come back from global. Perhaps you a numeric argument of "1" (as opposed to c-u which is already used up) can be used to add this "-l" option?

Also, ggtags.el is long (and good) - i could not find where for the gtags-global buffer you shorten the long path names to just single characters for directory names. Whereever that is done, could that not be a place to re-order this list by putting things "nearest" to point first in the list? (I will be happy to try to code this up w/ some hints as to if this possible and where might this be done in ggtags.el. (Or is this path name shortening done elsehwere?)

Thanks again for good stuff that is ggtags.

@leoliu
Copy link
Owner

leoliu commented May 24, 2015

Limit matches to directory sounds like a fine idea. I'll see to it soonish.

Ordering is harder. We have to wait until getting all matches before re-ordering it. At the moment, ggtags is async by means of compile.el. I think this feature might be best implemented in global itself.

@gthaker
Copy link
Author

gthaker commented May 24, 2015

Thanks LeoLiu for a rapid response. I will look for this "limit matches to directory" feature when you get to it - appreciate it. Also, understand about async nature of use of global, I may try to find if global has a forum where I might put this idea to them.

@leoliu
Copy link
Owner

leoliu commented May 24, 2015

no worries. Yes, global has a mailing list: http://www.gnu.org/software/global/maillist.html

@gthaker
Copy link
Author

gthaker commented May 25, 2015

As an update, I posted to global maillist and got the positive response below. I have downloaded the patch and tried it, and it seems to do what I would expect. Hopefully Leo can implement the "local" option in near future, and then once this feature makes it into global a way can be found to incorporate it as well. (Hopefully "local" would be an easy optional arg or a new function.)

Gautam

from: [email protected]

Hi,
It's very interesting. I have made a patch for it.

The -N (--nearest) option is available with the -S or -l option.

$ cd libutil
$ global -xl main # local search -> not found
$ global -xl main -N # nearest search
main 363 ../global/global.c main(int argc, char *_argv)
main 198 ../gozilla/gozilla.c main(int argc, char *_argv)
...

Would you please try it?

Regards,
Shigio

@gthaker
Copy link
Author

gthaker commented May 28, 2015

To keep information flow uptodate I have had the following additional email from Shigio (a developer on 'global')

Hi,
Thank you for your trial.

Inspired by your idea, I'm thinking about new sort method 'Nearness sort' of
global(1)'s output. Basic idea is 'What will happen if we do not stop
"nearest process" on the way?'

Nearness sort is invoked by the following option:

$ global -x main --nearness-sort

Nearness sort is based on the following priority.
( means priority. has higher priority than <n+1>)

<1> files under the current directory
<2> files under the parent directory except for the files which have higher priority.
<3> files under the grandparent directory except for the files which have higher priority.
... (repeat until the project root directory)

In every priority, they are sorted by alphabetical order.

@leoliu
Copy link
Owner

leoliu commented May 28, 2015

Lovely, I'll see what can be done in the weekend. Thanks for getting this feature done upstream ;)

@gthaker
Copy link
Author

gthaker commented Jun 4, 2015

To Update once again. Global developer has patched his repo w/ this new capability. I assume it will be in the next release of global. I have downloaded and built the new "global" with this patch, and would like to try it out w/ ggtags (as it gets modified by leoliu). The options --local and --nearness are the once to somehow make available to users of ggtags. I suggest that they be functions that can be bound to keys/mouse by user or would get used based on numeric argument to existing functions (M-., etc.)

Thanks again for ggtags.

-l, --local
Print only tags which exist under the current directory.
...
-n, --nofilter
Suppress sort filter and path conversion filter.
-N, --nearness
Use Nearness sort method for the output of tag search command.
By default, alphabetical sort method is used.
Nearness sort is an extension facility of local search (-l, --local).
The result of nearness sort is concatenation of the followings ([1]-[n])
in this order.
@begin_verbatim
[1] Output of local search in the current directory.
[2] Output of local search in the parent directory except for [1].
[3] Output of local search in the grandparent directory except for [1]-[2].
(repeat untill the project root directory)
[n] Output of local search in the project root directory except for [1]-[n-1].
@end_verbatim
In each directory, they are sorted by alphabetical order.

@gthaker
Copy link
Author

gthaker commented Jun 5, 2015

I was unsure if I should post this much but here it goes.

I have a patched "global" that I am using to try to get a jump start on this by trying to use the "-N" option in ggtags.el myself. Here is what I have learned and shared with global developer.

--- included text
so, I am trying to get a jump on leo liu and trying to make use of global's "-N" option. However, I am seeing this that I don't quite understand.

My project root is:

/proj/home/gthaker/OpenSplice_from_src/OpenSpliceDDS

I am working deep in it at:

/proj/home/gthaker/OpenSplice_from_src/OpenSpliceDDS/install/HDE/x86.linux-debug/examples/dcps/HelloWorld/c/src

I from ........./c/src above I invoke this "-N" option things work well (nearness is followed.)

mint17-32bits> global -N createParticipant
DDSEntitiesManager.c
../../cpp/src/DDSEntityManager.cpp
../../java/src/DDSEntityManager.java
../../../BuiltInTopics/c/src/DDSEntitiesManager.c
../../../BuiltInTopics/cpp/src/DDSEntityManager.cpp

However, ggtags.el ends up invoking it from root of project as:

mint17-32bits> global -N --from-here=55:install/HDE/x86.linux-debug/examples/dcps/HelloWorld/c/src/HelloWorldDataPublisher.c createParticipant
examples/dcps/BuiltInTopics/c/src/DDSEntitiesManager.c
examples/dcps/BuiltInTopics/cpp/src/DDSEntityManager.cpp
examples/dcps/ContentFilteredTopic/c/src/DDSEntitiesManager.c
examples/dcps/ContentFilteredTopic/cpp/src/DDSEntityManager.cpp
examples/dcps/ContentFilteredTopic/java/src/DDSEntityManager.java
examples/dcps/Durability/c/src/DDSEntitiesManager.c
examples/dcps/Durability/cpp/src/DDSEntityManager.cpp
examples/dcps/Durability/java/src/DDSEntityManager.java
examples/dcps/HelloWorld/c/src/DDSEntitiesManager.c
....

And in this case "global" does not return "examples/dcps/HelloWorld/c/src/DDSEntitiesManager.c" as first choice though this is nearest.

Just sharing in hopes this is worthy of a comment.

Gautam

@leoliu
Copy link
Owner

leoliu commented Jun 6, 2015

Hi @gthaker,

Thanks for the updates. I have just built global CVS and I am looking into how best to ingrate it into ggtags. As you have noted ggtags runs from the project root (if I remember correctly it was so that one could symlink a directory into a project, for example, ln -s /usr/include/libxml2 .) which we might have to change.

Cheers,
Leo

@leoliu
Copy link
Owner

leoliu commented Jun 6, 2015

Hi @gthaker,

Could you try it out and send me any comments that you may have? You need to set ggtags-sort-by-nearness to t to use the nearness sort.

Thanks.
Leo

@gthaker
Copy link
Author

gthaker commented Jun 8, 2015

I have downloaded from the repo, set ggtags-sort-by-nearness to t and tried this out. It seems to work well, the "nearest" definition is found first.

In the process of testing all this I do have one question. (I am relatively new to global and ggtags, so please forgive me if this is a naive question.) I start w/ a M-. and find one of 54 definitions. (The nearest is first, so I am good there.) I then do, as testing, some M-, command, and move down to say D8/D54. I then do M-* to abort navigation and return to where I started.

If I next do another M-. it starts at D8 again! I had thought that M-. would just start the process again as I had "aborted", and would start with D1, and M-, would resume at D8. Can you help me understand better? Thanks.

Gautam

@leoliu
Copy link
Owner

leoliu commented Jun 9, 2015

hi @gthaker,

See ggtags-auto-jump-to-match.

Leo - sent from my phone

@gthaker
Copy link
Author

gthaker commented Jun 9, 2015

OK, thanks. I set my ggtags-auto-jump-to-match to "first", works great.

BTW, this entry above " add --scope' argument support whenglobal' command is built. #100", what does it actually mean? I can't find an issue #100 in either open or close issues list. Just asking...

@leoliu
Copy link
Owner

leoliu commented Jun 9, 2015

That is a pull request.

@leoliu leoliu closed this as completed Jun 11, 2015
@kaushalmodi
Copy link

The nearness feature is released in version 6.5: http://lists.gnu.org/archive/html/info-global/2015-06/msg00000.html

@gthaker
Copy link
Author

gthaker commented Jun 20, 2015

Hi:

I have been using global/ggtags (including its latest "nearness" capability), and it is working well for me. I have another question. Can global/ggtags be asked to return a tag for a fully qualifed C++ name such as:

retval = OpenDDS::DCPS::DataWriterImpl::write( ...);

In this software there are 202 "write()" functions, and getting to the correct one quickly would be a nice help. In this case when I ask global to find this "write" method there is no way, it seems, to tell it the full, entirely qualified name (nor does ggtags try to use the fully qualified name in what it asks global to find - prob. because global doesn't seem to support fully qualified names). Since OpenDDS::DCPS:: are namespace qualifiers it would be nice if global recognized that closest entry is one with the line:

path/path1/DataWriterImpl.cpp:1691:DataWriterImpl::write(..)

No other entry out of 202 comes close to this match. Is it possible for global to somehow find this entry correctly? "nearness" works great, and has already saved me much time in navigating around. This case of fully qualified names I wish there was support for (or if it exists and I have missed seeing it pl. let me know.)

Gautam

@leoliu
Copy link
Owner

leoliu commented Jun 21, 2015

Hi @gthaker,

It seems it is impossible at the moment. Many people have requested this feature in global's mailing list. Could you try making a case there and may you have a better luck?

Cheers,
Leo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants