joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.23k stars 139 forks source link

Fix #470: Handle case when there is no emacs-connection. #619

Closed aadcg closed 8 months ago

aadcg commented 9 months ago

Closes #470.

My use-case is as follows: Nyxt depends on slynk/indentation and lass, which in turn calls indent:define-indentation from trivial-indent. Without this fix, it would raise the error below.

debugger invoked on a SB-KERNEL:CASE-FAILURE @5436DF2E in thread
#<THREAD tid=19916 "main thread" RUNNING {10017401B3}>:
  NIL fell through ETYPECASE expression.
  Wanted one of (SLYNK::SINGLETHREADED-CONNECTION
                 SLYNK::MULTITHREADED-CONNECTION).

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [TRY-RECOMPILING              ] Recompile special and try loading it again
  1: [RETRY                        ] Retry
                                     loading FASL for #<CL-SOURCE-FILE "lass" "special">.
  2: [ACCEPT                       ] Continue, treating
                                     loading FASL for #<CL-SOURCE-FILE "lass" "special">
                                     as having been successful.
  3:                                 Retry ASDF operation.
  4: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
                                     configuration.
  5:                                 Retry ASDF operation.
  6:                                 Retry ASDF operation after resetting the
                                     configuration.
  7: [RETRY                        ] Retry EVAL of current toplevel form.
  8: [CONTINUE                     ] Ignore error and continue loading file "/gnu/store/qk4jx7p95ff6iyr4pn6h7bvh599hjj54-profile/bin/lisp-repl-core-dumper".
  9: [ABORT                        ] Abort loading file "/gnu/store/qk4jx7p95ff6iyr4pn6h7bvh599hjj54-profile/bin/lisp-repl-core-dumper".
 10:                                 Ignore runtime option --eval "(with-open-file (s \"/gnu/store/qk4jx7p95ff6iyr4pn6h7bvh599hjj54-profile/bin/lisp-repl-core-dumper\")
  (read-line s)
  (load s))".
 11:                                 Skip rest of --eval and --load options.
 12:                                 Skip to toplevel READ/EVAL/PRINT loop.
 13: [EXIT                         ] Exit SBCL (calling #'EXIT, killing the process).

(SLYNK::SEND-TO-INDENTATION-CACHE (:UPDATE-INDENTATION-INFORMATION))
   source: (ETYPECASE C
             (SINGLETHREADED-CONNECTION
              (HANDLE-INDENTATION-CACHE-REQUEST C REQUEST))
             (MULTITHREADED-CONNECTION
              (WITHOUT-SLY-INTERRUPTS
               (SEND (MCONN.INDENTATION-CACHE-THREAD C) REQUEST))))
0] 
aadcg commented 8 months ago

@joaotavora friendly ping.

joaotavora commented 8 months ago

OK, I merged this with a tweak to the commit message (in the future, using the format described in CONTRIBUTE and used in other commits is advisable)

But I still don't understand the use case.The backtrace is cut off after the first frame: seeing more frames would clear it up.

aadcg commented 7 months ago

For future reference, trivial-indent defines the with-symbol macro that executes foo-body when module "SLYNK/INDENTATION" is loaded on the following call (with-symbol (foo-name foo-symbol :slynk "SLYNK/INDENTATION") foo-body). In other words, when module "SLYNK/INDENTATION" isn't loaded (the usual case when compiling CL code in a non-interactive fashion) then the body of with-symbol is a no-op and this case doesn't need to be handled.

While rare, slynk/indentation may be a member of *modules*, which justifies this fix.