Compile a file with these contents:
-------------------------------------
(cl:defpackage :xxx (:use #:common-lisp))
(in-package :xxx)
(named-readtables:in-readtable pythonic-string-reader:pythonic-string-syntax)
(defun foo () """ "#<>" """)
(defun bar ())
-------------------------------------
Press M-. on BAR, it works. Open the scratch buffer, type XXX::BAR and press M-. on it to get (with *DEBUG-SWANK-BACKEND* T):
-------------------------------------
illegal sharp macro character: #<
Line: 9, Column: 11, File-Position: 167
Stream: #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> [Condition of type SB-INT:SIMPLE-READER-ERROR]
Restarts: 0: [*ABORT] Return to SLIME's top level. 1: [ABORT] abort thread (#<THREAD "worker" RUNNING {102386D683}>)
Backtrace: 0: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGING-ENVIRONMENT :IN "/home/mega/quicklisp/local-projects/slime/swank/sbcl.lisp") #<FUNCTION (LAMBDA NIL :IN SWANK::DEBUG-IN-EMACS) {1007266DEB}>) 1: (SWANK::DEBUG-IN-EMACS #<SB-INT:SIMPLE-READER-ERROR "illegal sharp macro character: ~S" {102387D713}>) 2: (SWANK:INVOKE-SLIME-DEBUGGER #<SB-INT:SIMPLE-READER-ERROR "illegal sharp macro character: ~S" {102387D713}>) 3: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL :IN SWANK:SWANK-DEBUGGER-HOOK) {102387E08B}>) 4: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "/home/mega/quicklisp/local-projects/slime/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL :IN SWANK:SWANK-DEBUGGER-HOOK).. 5: (SWANK:SWANK-DEBUGGER-HOOK #<SB-INT:SIMPLE-READER-ERROR "illegal sharp macro character: ~S" {102387D713}> #<unavailable argument>) 6: (SB-DEBUG::RUN-HOOK *DEBUGGER-HOOK* #<SB-INT:SIMPLE-READER-ERROR "illegal sharp macro character: ~S" {102387D713}>) 7: (INVOKE-DEBUGGER #<SB-INT:SIMPLE-READER-ERROR "illegal sharp macro character: ~S" {102387D713}>) 8: (ERROR SB-INT:SIMPLE-READER-ERROR :STREAM #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> :FORMAT-CONTROL "illegal sharp macro character: ~S" :FORMAT-ARGUMENTS (#<)) 9: (SB-INT:SIMPLE-READER-ERROR #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> "illegal sharp macro character: ~S" #<) 10: (SB-IMPL::SHARP-ILLEGAL #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> #< #<unavailable argument>) 11: (SB-IMPL::READ-MAYBE-NOTHING #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> ##) 12: (SB-IMPL::READ-LIST #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> #<unavailable argument>) 13: (SB-IMPL::READ-MAYBE-NOTHING #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> #() 14: (SB-IMPL::%READ-PRESERVING-WHITESPACE #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> T (NIL) T) 15: (SB-IMPL::%READ-PRESERVING-WHITESPACE #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> T (NIL) NIL) 16: (SB-IMPL::%READ-PRESERVING-WHITESPACE #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> T (NIL) NIL) [tl,external] 17: (READ #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}> T NIL NIL) 18: (SWANK/SOURCE-PATH-PARSER::SKIP-TOPLEVEL-FORMS 4 #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}>) 19: (SWANK/SOURCE-PATH-PARSER:READ-SOURCE-FORM 4 #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}>) 20: (SWANK/SOURCE-PATH-PARSER::SOURCE-PATH-STREAM-POSITION (4) #<SB-IMPL::STRING-INPUT-STREAM {102387D1B3}>) 21: (SWANK/SOURCE-PATH-PARSER:SOURCE-PATH-STRING-POSITION (4) "(cl:defpackage :xxx ..) 22: (SWANK/SBCL::CALL-WITH-DEBOOTSTRAPPING #<CLOSURE (LAMBDA NIL :IN SWANK/SBCL::SOURCE-FILE-POSITION) {102387D19B}>) 23: (SWANK/SBCL::SOURCE-FILE-POSITION "/home/mega/own/mgl-pax/src/x.lisp" 3631296724 (4)) 24: (SWANK/SBCL::DEFINITION-SOURCE-FILE-LOCATION #S(SB-INTROSPECT:DEFINITION-SOURCE :PATHNAME #P"/home/mega/own/mgl-pax/src/x.lisp" :FORM-PATH (4) :CHARACTER-OFFSET 177 :FILE-WRITE-DATE 3631296724 :PLIST .. 25: ((FLET SWANK/BACKEND:FIND-DEFINITIONS :IN "/home/mega/quicklisp/local-projects/slime/swank/sbcl.lisp") XXX::BAR) 26: (SWANK:FIND-DEFINITIONS-FOR-EMACS "xxx::bar") 27: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:FIND-DEFINITIONS-FOR-EMACS "xxx::bar") #<NULL-LEXENV>) 28: (EVAL (SWANK:FIND-DEFINITIONS-FOR-EMACS "xxx::bar")) 29: (SWANK:EVAL-FOR-EMACS (SWANK:FIND-DEFINITIONS-FOR-EMACS "xxx::bar") "COMMON-LISP-USER" 381)
-------------------------------------
So the source location has the index of the top-level form in the file (4) and swank tries to skip some forms by reading which, even with *READ-SUPPRESS* T, fails on #<.
There are three options that I can see:
A. Make SOURCE-FILE-POSITION find the right readtable for the file. Currently has logic for SB! only.
B. Record the absolute position of the form in the file.
C. Apply some heuristics to SKIP-TOPLEVEL-FORMS.
OK. C is ugly and fragile, B is just fragile, A requires changes in both NAMED-READTABLES and SLIME/SWANK. Perhaps, you have better ideas?
Cheers, Gabor
Press M-. on BAR, it works. Open the scratch buffer, type XXX::BAR and press M-. on it to get (with *DEBUG-SWANK-BACKEND* T):
i have this patch in my repo unmerged for 4+ years now. i'm not sure anymore, but i think it's a fix for that:
Fix: source-path-parser honours the readtables specified in swank:*readtable-alist* https://github.com/attila-lendvai/slime/commit/743018eb04dafd647c31bd66682b4...
Attila Lendvai attila@lendvai.name writes:
Press M-. on BAR, it works. Open the scratch buffer, type XXX::BAR and press M-. on it to get (with *DEBUG-SWANK-BACKEND* T):
i have this patch in my repo unmerged for 4+ years now. i'm not sure anymore, but i think it's a fix for that:
Fix: source-path-parser honours the readtables specified in swank:*readtable-alist* https://github.com/attila-lendvai/slime/commit/743018eb04dafd647c31bd66682b4...
Thanks, it works. Here is a rebased and cleaned up version:
https://github.com/melisgl/slime/commit/a23a250936277a9053b5a8c98b6e4f2be3f7...
Maintainers, everyone, I'm not sure about the two KLUDGEs related to accessing stuff from the SWANK package. What's the best way to deal with them?
mega@retes.hu (Gábor Melis) writes:
Attila Lendvai attila@lendvai.name writes:
Press M-. on BAR, it works. Open the scratch buffer, type XXX::BAR and press M-. on it to get (with *DEBUG-SWANK-BACKEND* T):
i have this patch in my repo unmerged for 4+ years now. i'm not sure anymore, but i think it's a fix for that:
Fix: source-path-parser honours the readtables specified in swank:*readtable-alist* https://github.com/attila-lendvai/slime/commit/743018eb04dafd647c31bd66682b4...
Thanks, it works. Here is a rebased and cleaned up version:
https://github.com/melisgl/slime/commit/a23a250936277a9053b5a8c98b6e4f2be3f7...
Disregard the above link. I added a changelog entry and also two small fixes as separate commits and create a pull request:
https://github.com/slime/slime/pull/224
But this still stands:
Maintainers, everyone, I'm not sure about the two KLUDGEs related to accessing stuff from the SWANK package. What's the best way to deal with them?
On Tue, Jan 27 2015, Gábor Melis wrote:
Maintainers, everyone, I'm not sure about the two KLUDGEs related to accessing stuff from the SWANK package. What's the best way to deal with them?
Either pass the context in as argument or create a new back-end function that the front-end must call first to configure the back-end. Both look rather clumsy in this case. As expected: reader macros attract kludges like shit attracts flies.
Helmut
Helmut Eller eller.helmut@gmail.com writes:
On Tue, Jan 27 2015, Gábor Melis wrote:
Maintainers, everyone, I'm not sure about the two KLUDGEs related to accessing stuff from the SWANK package. What's the best way to deal with them?
Either pass the context in as argument or create a new back-end function that the front-end must call first to configure the back-end. Both look rather clumsy in this case. As expected: reader macros attract kludges like shit attracts flies.
Thanks. I removed one of the kludges by using SWANK/BACKEND:*DEBUG-SWANK-BACKEND*. The cure for the other was worse than the disease, so that remains. Xach, this has the side effect of fixing the interning problem.
https://github.com/slime/slime/pull/224
I consider this final, unless there is an unexpected problem with it.
On Tue, Jan 27 2015, Gábor Melis wrote:
Thanks. I removed one of the kludges by using SWANK/BACKEND:*DEBUG-SWANK-BACKEND*. The cure for the other was worse than the disease, so that remains. Xach, this has the side effect of fixing the interning problem.
This still interns just in a different package.
I consider this final, unless there is an unexpected problem with it.
I don't like it much but I merged it in anyway, hoping that this is the last time that I have to deal with reader macros.
Helmut
On Mon, Jan 26 2015, Gábor Melis wrote:
OK. C is ugly and fragile, B is just fragile, A requires changes in both NAMED-READTABLES and SLIME/SWANK. Perhaps, you have better ideas?
D: don't create reader macros that need A, B, or C. That's what I do.
E: invent some magic comment or re-use Emacs's syntax for file variables e.g. ;; -*- readtable: ... -*- and recognize it in swank/source-path-parser.lisp. Or search directly for lines matching "^(named-readtables:in-readtable .*)"
F: get rid of swank/source-path-parser.lisp entirely and tell the SBCL maintainers that they should represent source locations as a file:line:column triple instead of source paths.
Helmut
Helmut Eller eller.helmut@gmail.com writes:
On Mon, Jan 26 2015, Gábor Melis wrote:
OK. C is ugly and fragile, B is just fragile, A requires changes in both NAMED-READTABLES and SLIME/SWANK. Perhaps, you have better ideas?
D: don't create reader macros that need A, B, or C. That's what I do.
That's what I normally do, too.
E: invent some magic comment or re-use Emacs's syntax for file variables e.g. ;; -*- readtable: ... -*- and recognize it in swank/source-path-parser.lisp. Or search directly for lines matching "^(named-readtables:in-readtable .*)"
Right, this is an implementation of A.
F: get rid of swank/source-path-parser.lisp entirely and tell the SBCL maintainers that they should represent source locations as a file:line:column triple instead of source paths.
This is what I meant by B. But in some sense it would be a step backwards, because the location today is not sensitive to editing within toplevel forms.