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

dumb-jump not finding declaration in extremely simple C example #128

Closed
esthermations opened this issue Apr 20, 2017 · 3 comments
Closed

Comments

@esthermations
Copy link

It's likely this is a problem with my setup, but I can't get dumb-jump to work for C at all.

Here's what I'm trying to get working. I have a folder with just two files in it, test.c and test.h.

This is test.c:

#include "test.h"
int main(void) { some_function(); return 0; }

And this is test.h:

void some_function(void) { return; }

If I navigate to some_function() in test.c and do M-x dumb-jump-go or any other dumb-jump command, it fails to find the declaration of some_function in test.h. Changing the whitespace around doesn't seem to change anything.

Can anyone reproduce this? It seems like the simplest possible use case for the program. I'm convinced it must be a problem with my setup, but I don't know.

Thanks.

@jacktasia
Copy link
Owner

jacktasia commented Apr 20, 2017

Thanks for the report.

Using this gist which has your example:

git clone https://gist.github.com/jacktasia/e1dd2be88b2d72b1c8b1f0154dfea8d2 c-test
cd c-test/
emacs test.c

It works fine for me, but when cloned it will create a .git/ directory in c-test, so dumb-jump knows the project root. If it can't figure out the project root it's going to use your home directory, which probably has a ton of stuff and thus slow (which it should warn you about).

Please try adding an empty .dumbjump file to the directory with your test files (touch .dumbjump). If that doesn't work then please do a (setq dumb-jump-debug t) and reply back here with what the debug output in your *Messages* buffer. Thanks!

@esthermations
Copy link
Author

Okay, thanks for that. I couldn't get it to print any debug info, so I tried deleting and re-installing dumb-jump, which solved the issue and it now works as expected. I have no idea how my dumb-jump package got broken like that, but it's fixed now. Thanks!

@josefig
Copy link

josefig commented Dec 31, 2020

Hello @jacktasia

Just for the record. I tried this example and didn't work, my Mesages were showing with rg that was not working because the build I had didn't support PCRE2. So I tried with grep but this version of grep didn't have the --include option. After trying I found that the ag (the silver searcher) is working now.

I am using OpenBSD -current. So maybe if someone else is using OpenBSD might find this useful. Thanks.

----- *Messages * -----

DUMB JUMP DEBUG ‘dumb-jump-run-command‘ START
----

cmd:
	rg --color never --no-heading --line-number -U --pcre2 --type c --type cpp \\bsome_function\(\\s\|\\\)\)\*\\\(\(\\w\|\[\,\&\*.\<\>\:\]\|\\s\)\*\(\\\)\)\\s\*\(const\|-\>\|\\\{\|\$\)\|typedef\\s\+\(\\w\|\[\(\*\]\|\\s\)\+some_function\(\\\)\|\\s\)\*\\\(\|\\b\(\?\!\(class\\b\|struct\\b\|return\\b\|else\\b\|delete\\b\)\)\(\\w\+\|\[\,\>\]\)\(\[\*\&\]\|\\s\)\+some_function\\s\*\(\\\[\(\\d\|\\s\)\*\\\]\)\*\\s\*\(\[\=\,\(\)\{\;\]\|\:\\s\*\\d\)\|\#define\\s\+some_function\\b\|\\b\(class\|struct\|enum\|union\)\\b\\s\*some_function\\b\\s\*\(final\\s\*\)\?\(\:\(\(\\s\*\\w\+\\s\*\:\:\)\*\\s\*\\w\*\\s\*\<\?\(\\s\*\\w\+\\s\*\:\:\)\*\\w\+\>\?\\s\*\,\*\)\+\)\?\(\(\\\{\|\$\)\)\|\}\\s\*some_function\\b\\s\*\; /home/josefig/Documents/projects/c-test

rawresults:
	PCRE2 is not available in this build of ripgrep



-----
DUMB JUMP DEBUG ‘dumb-jump-run-command‘ END
-----
DUMB JUMP DEBUG ‘nil‘ START
----

look-for:
	some_function

(plist-get info :ctx-type):
	

var-to-jump:
	nil

(pp-to-string match-cur-file-front):
	nil

(pp-to-string results):
	nil

match-cur-file-front:
	nil

proj-root:
	/home/josefig/Documents/projects/c-test

(plist-get info :file):
	/home/josefig/Documents/projects/c-test/test.c


-----
DUMB JUMP DEBUG ‘nil‘ END
-----
’some_function’ c++  declaration not found.
user-error: No definitions found for: some_function

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