emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make cscope/global searching more precise (with the infomation where you


From: Haojun Bao
Subject: Make cscope/global searching more precise (with the infomation where you started the search)
Date: Tue, 09 Nov 2010 09:38:02 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

When searching a function/struct definition, if there is only one
definition, then everything is fine. But considering a big codebase
like kernel/android, there could be many. 

For e.g., when reading android's system/core/init, I want to check the
definition of `parse_state` with cscope, and the result is like the
following, I need to use my eyeball to find that the last one is the one
I'm actually looking for (and then move the cursor over it to do the jump):


    *** /home/bhj/src/cupcake/external/e2fsprogs/e2fsck/profile.c:
    parse_state[152]               struct parse_state {
    
    *** 
/home/bhj/src/cupcake/external/freetype/include/freetype/internal/psaux.h:
    parse_state[574]               T1_ParseState parse_state;
    
    *** /home/bhj/src/cupcake/external/iptables/extensions/libip6t_state.c:
    parse_state[32]                parse_state(const char *state, size_t 
strlen, struct ipt_state_info *sinfo)
    
    *** /home/bhj/src/cupcake/external/iptables/extensions/libipt_conntrack.c:
    parse_state[60]                parse_state(const char *state, size_t 
strlen, struct ipt_conntrack_info *sinfo)
    
    *** /home/bhj/src/cupcake/external/iptables/extensions/libipt_state.c:
    parse_state[32]                parse_state(const char *state, size_t 
strlen, struct ipt_state_info *sinfo)
    
    *** /home/bhj/src/cupcake/system/core/init/parser.c:
    parse_state[69]                struct parse_state
    
This can be improved by calculating starting/resulting file name's
distance. Since here I started the cscope search in a file in
system/core/init, the last entry above is the closest one, and thus
should come as the first!

And it can be easily done using perl's String::Approx module. As an e.g.,
see 
http://github.com/baohaojun/windows-config/raw/master/bin/linux/gtags-cscope-bhj

With this small trick, in most cases, the first one is the one I'm
looking for, no further ado. And the worst case? let's just forget that
we are calculating distance and use eyeballs again:-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]