jacktasia / dumb-jump

an Emacs "jump to definition" package for 50+ languages
GNU General Public License v3.0
1.57k stars 150 forks source link

dumb-jump-go not helpful for C (way too many results) #310

Open asn-d6 opened 4 years ago

asn-d6 commented 4 years ago

Hello there,

I started using dumb-jump a few weeks ago over my old cscope/etags setup. I really like the no-setup approach, but dumb-jump-go basically never works as intended in my C projects.

In particular when I do dumb-jump-go over a function, it just gives me a tooltip that includes all the definitions, prototypes and references of the function (even references inside comments). It's almost as it does no effort to actually find and jump to the definition. This is basically a blocker for me because for functions that are used a lot, I just have to endlessly go through the tooltip and find the definition myself... This is a big step backwards over my old cscope/etags setup.

As an example, clone this repo and try to dumb-jump-go for rend_service_receive_introduction in https://github.com/torproject/tor/blob/master/src/feature/hs/hs_service.c#L3888 . This is just an example, and you will get the same results for basically any function you try to find the definition of.

I also tested this on C++ projects and I still get the tooltip with the prototype of the function as an option.

Could it be that the regexp is not well tuned? I toggled dumb-jump-debug and tried to tweak the regexp, but I felt that this is not the way to go and it was a PEBCAK of some sorts.

Please help me out here, because I don't want to go back to The old ways.

Thanks! :)

xianbaum commented 4 years ago

The regex could definitely use some fine tuning, but dumb-jump will never compare to ctags/etags/rtags/gtags/cscope so I wouldn't exactly call those "the old ways". C is a difficult language to parse. Even ignoring macros, it's very context specific, so with regex alone it's hard to tell the difference between a variable definition, type definition, assignment, function, etc, and there are often multiple definitions for the same symbol that are enabled or disabled during build.

dumb-jump is often good enough when you don't want to or can't use an indexing tool like ctags. A project like Tor is massive though, so ctags/whatever is probably a better tool for that one.

S4deghN commented 9 months ago

I wonder if you found a good way to use dumb-jump for C because I'm facing the same issue. @asn-d6