If the Lisp system provides a snippet hint for a source location, `slime-goto-source-location' uses `slime-isearch' to find the nearest occurrence of it in order to narrow down the location better, and subsequently uses `slime-search-call-site' to narrow it down even further. However, the search may send the point off into some random place in the file, even in a completely different defun, but then `slime-search-call-site' narrows itself to whichever defun it's on and searches *there*, so if `slime-isearch' got lost then the whole thing will get lost.
Is there a reason that `slime-goto-source-location' does not narrow to the defun before running `slime-isearch'? The above problem is solved by this simple patch:
Index: slime.el =================================================================== RCS file: /project/slime/cvsroot/slime/slime.el,v retrieving revision 1.605 diff -u -r1.605 slime.el --- slime.el 26 Mar 2006 03:51:56 -0000 1.605 +++ slime.el 30 Mar 2006 23:51:34 -0000 @@ -5043,7 +5043,9 @@ (slime-goto-location-buffer buffer) (slime-goto-location-position position) (when-let (snippet (getf hints :snippet)) - (slime-isearch snippet)) + (save-restriction + (narrow-to-defun) + (slime-isearch snippet))) (when-let (fname (getf hints :call-site)) (slime-search-call-site fname))) ((:error message)
* Taylor R. Campbell [2006-03-31 01:59+0200] writes:
Is there a reason that `slime-goto-source-location' does not narrow to the defun before running `slime-isearch'? The above problem is solved by this simple patch:
It's intentional that slime-isearch can move to a different defun.
The snippet is intended for the case when the buffer position of the source location is stale e.g. because the user inserted a new defun before that position. The CMUCL swank records the source string for functions compiled with C-c C-c and the snippet is extracted from that string.
The :call-site hint is intended for implementations which only record the beginning of functions and not the source locations inside functions.
None of our backends uses the :snippet and :call-site hints at the same time.
Helmut.
Hmm, OK, thanks. I'm in a bit of a fix, though, since I want essentially :SNIPPET but narrowed to the defun -- Scheme48 provides the source code for every expression that will have a continuation, but in a form that doesn't necessarily correspond with the source text literally (since it's in S-expression form, not text form), so I want to use slime-isearch. This is more information, too, than :CALL-SITE can deal with. Would it make sense to have, or would anyone object to having, another hint, say :CALL-SNIPPET, which would work like :SNIPPET but narrow to the defun first? The implementation is trivial -- it would simply be the patch I sent, but without the removal of :SNIPPET.
(Of course, the right thing would be for Scheme48 to provide better proper source location in the form of paths down the S-expression tree. But that requires changes to Scheme48 itself, and my efforts to get changes on the Scheme48 end haven't been very fruitful, unfortunately...)