Open sorawee opened 5 years ago
It doesn't do that because it takes (potentially a lot) of time to find the definition. So it jumps to the definition only when it already knows where the definition is.
On Tue, May 14, 2019 at 12:47 AM sorawee notifications@github.com wrote:
There are two cases when jump-to-definition-callback https://github.com/racket/drracket/blob/master/drracket/drracket/private/syncheck/gui.rkt#L1877 is called: the file with the definition has not been opened, or is already opened. If it's already opened, DrRacket will jump to definition as expected. However, if it has not been opened, it will simply open the defining file without jumping to definition. Making it jumping to definition too would be an improvement.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/racket/drracket/issues/273?email_source=notifications&email_token=AADBNMHNFFW3JLA5MWVH3O3PVJG53A5CNFSM4HMWPDCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GTSUWGA, or mute the thread https://github.com/notifications/unsubscribe-auth/AADBNMHX2GFBXYHUDAXJWWTPVJG53ANCNFSM4HMWPDCA .
Could this be a timed-out jump? If it succeeds in N ticks, it does; otherwise it doesn't?
That sounds confusing to the user to me. I think probably it makes sense to have two things, one where you commit to wait up front and one where you get the present behavior (open the file if the definition's location isn't yet known and go to the definition if it is known (where "known" here mean that online check syntax has completed in the file)).
The second option could show a clock or something to indicate that it timed out. But I gave often wanted what Oak asked for but you told me about the "takes a long time" before.
An alternative would be to index the files up front ..
An alternative would be to index the files up front ..
The better alternative
Yes, I agree that some kind of indexing is the best option here. @chrdimo and I started working on a layer to provide that but I got distracted on picking it up and finishing it off.
As a user of both racket-mode and DrRacket, the heuristic approach that racket-mode uses works really well and I would appreciate having DrRacket do that in a similar way.
Is there some code that racket-mode and drracket could share here?
I think @greghendershott could point to the relevant racket-mode code but DrRacket already has the code to heuristically generate the "jump to definition" drop-down for each file so it could use that.
The Racket Mode code is https://github.com/greghendershott/racket-mode/blob/master/racket/find.rkt.
I haven't worked on this code in a couple years, so if you have questions, it would take me awhile to fully reload my brain. View from orbit, my experience is that you can find some definitions from fully expanded syntax... but as a fallback might need to look at pre-expanded. [There is also code in that file to find "signatures" (i.e. something to show users in lieu of an actual bluebox), in which case digging through pre-expanded surface syntax is even more useful.]
Racket Mode maintains an in-memory cache of syntax (both pre-expanded and expanded). The keys include files on disk, as well as code strings that exist only in non-saved code buffers. The cache can be warmed by check syntax having already run, or by a compiled load handler (so require
d files might already be in the cache), or by some other command wanting syntax for the file or buffer.
So often it's pretty fast. Even so, this is done "asynchronously" in Racket Mode, i.e. the user can keep using Emacs while the search is happening, including expansion if that needs to happen because there's a cache miss.
I'm 100% open to sharing. How, exactly? Often this can be tricky to do in the form of a shared package because Racket Mode supports older versions of Racket than you would want to support.
At the very least I'm happy to share in terms of you using the code as a head start (whether you regard it as a model or anti-model, either way. :smile:). And if it seems like an actual shared package is possible and non-awkward, that would be great, too.
This issue has been mentioned on Racket Discussions. There might be relevant details there:
https://racket.discourse.group/t/opportunities-for-indexing/1321/1
There are two cases when
jump-to-definition-callback
is called: the file with the definition has not been opened, or is already opened. If it's already opened, DrRacket will jump to definition as expected. However, if it has not been opened, it will simply open the defining file without jumping to definition. Making it jumping to definition too would be an improvement.