all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Haojun Bao <baohaojun@gmail.com>
To: <emacs-devel@gnu.org>
Subject: Make cscope/global searching more precise (with the infomation where you started the search)
Date: Tue, 09 Nov 2010 09:38:02 +0800	[thread overview]
Message-ID: <87d3qfnuo5.fsf@baohaojun.rayzertrack.com> (raw)

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	other threads:[~2010-11-09  1:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d3qfnuo5.fsf@baohaojun.rayzertrack.com \
    --to=baohaojun@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.