joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.27k stars 145 forks source link

Avoiding the <2> in "*sly-mrepl for sbcl<2>*" (for Sly support for eepitch) #527

Open edrx opened 2 years ago

edrx commented 2 years ago

Hi João and other developers,

I am trying to add support for Sly to eepitch - a module of eev, that is explained here: http://angg.twu.net/eepitch.html - and I need some help...

I need to write a function called eepitch-sly that will have this behavior: 1) if sly is running, connected, etc, and it has a repl buffer, then just switch to its repl buffer - (sly-mrepl--find-buffer)? - and go to eob, a.k.a. the end of the buffer; 2) if sly is running and connected but its repl buffer has been deleted, then recreate it in the right way, switch to it, and go to eob; 3) is sly is not running then run it with all the defaults - skipping the questions -, wait until its repl buffer exists, is connected, and ready, and when all this has happened, then switch to its repl buffer, and return.

I know little Common Lisp at the moment, so I wrote the prototype below, that always uses SBCL - I can postpone making it more general until I have more experience...

(defun find-slyprocess ()
  "Go to a Sly REPL buffer, This function is used by `eepitch-sly'."
  (require 'sly)
  (sly-setup)
  (if (and (sly-current-connection)
       (sly-mrepl--find-buffer))
      (find-ebuffer (sly-mrepl--find-buffer) :end)
    (let ((sly-command-switch-to-existing-lisp 'never)
      (sly-auto-select-connection 'never)
      (sly-lisp-implementations '((sbcl ("sbcl"))))
      (sly-default-lisp 'sbcl))
      (sly))))

(defun eepitch-sly () (interactive)
  (eepitch '(find-slyprocess)))

It works - btw, I tried to write something similar for Slime and
failed miserably. I'm in love with Sly already =) - but if I kill the
repl buffer and run `find-slyprocess' again, and repeat that, then the
new repl buffers are called "*sly-mrepl for sbcl<2>*", "*sly-mrepl for
sbcl<3>*", and so on. How do I make Sly always use "*sly-mrepl for
sbcl*"?

Thanks in advance!

  Eduardo Ochs =)
  http://angg.twu.net/#eev
AkashaP commented 1 year ago

pretty late but shouldn't you switch to the existing buffer sly-mrepl for sbcl and use (sly-connect) instead?

edrx commented 1 year ago

What is the recommended way to do that? Just the sexp below, with a hardcoded name?

(switch-to-buffer "*sly-mrepl for sbcl*")