This is a post about M-. from Alan Ruttenberg which bounced for boring mailing list reasons. His idea sounds great to me. When I did something like this for MCL I used to search from the position of source the last time the form was compiled, downward, then upward on the theory they more often than not I was adding to the file. In the earlier version I used the (defxxx heuristic.
For openmcl I've been thinking that I should record the whole text (from the source file) of the definition with the function. What would be ideal would be to do a fuzzy search for the whole text, along the line of a BLAST alignment in genomics and choose the best matching position, (or even highlight where your code went in the case that you refactored :)
Note that M-. and finding the source location for a given PC in the debugger are implemented in almost the same way in this scenario. You associate with each PC the bounds of the definition form relative to the stored text for the function. Then, within the fuzzy match/alignment of the containing function you fuzzy match/align the source for the form being evaluated at the PC.
What's holding me back from trying this is having access to a fuzzy match algorithm. Does anyone know of one? Or have an idea of how to use some diff variant to get the same effect? Inside emacs would be ideal but we could also run a shell script on the buffer to get the match.
Saving all text and doing lots of computation to navigate to source may seem extravagant to some but it seems to me that the big bucks are in saving our time.
-Alan