srcrefs in swank:compile-string-for-emacs
Wow, this was hard. parse() constructs a vector with mode
"expression", consisting of multiple, possibly nested calls.
Scattered throughout this structure are srcrefs with absolute
locations. This means that we need to walk the parsed data structure
and adjust every srcref that we can find, giving it an offset based on
the location information passed to compile-string-for-emacs (which
requires bleeding-edge 2010-10-08 slime, because earlier versions
don't pass line/column information in the position argument).
But we can't simply adjust the "srcref" attribute on our parsed data
structure, because R tries very hard to be pure. Instead we need to
return a copy with the right modifications (but preserving everything
else of importance). It's straightforward once you know how, but
there were many painful missteps to get to this point. Still, now
M-. works on function names assigned with C-c C-c in source buffers.