Skip to content

Commit

Permalink
added slime-connect-unix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Nöllemeyer committed Aug 12, 2024
1 parent 0acd49d commit b702fac
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions extensions/lisp-mode/lisp-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,7 @@
(when (current-connection)
(abort-all (current-connection) "change connection")
(notify-change-connection-to-wait-message-thread))
(setf (current-connection) connection)
(when (repl-buffer)
(write-string-to-repl
(if (self-connection-p connection)
(format nil
"~%; changed connection (self connection)")
(format nil
"~%; changed connection (~A ~A)"
(connection-implementation-name connection)
(connection-implementation-version connection)))
:attribute 'syntax-comment-attribute)))
(setf (current-connection) connection))

(defmethod switch-connection ((connection connection))
(change-current-connection connection))
Expand Down Expand Up @@ -964,6 +954,29 @@
(when start-repl (start-lisp-repl))
(connected-slime-message connection)))

#+sbcl
(define-command slime-connect-unix (socket-path &optional (start-repl t))
((:splice
(list (prompt-for-string "Hostname: " :initial-value "/tmp/micros.sock"))))
(let ((connection (progn
(log:debug "Connecting to SWANK using UNIX socket")
(let* ((sock (make-instance 'sb-bsd-sockets:local-socket :type :stream))
(_ (sb-bsd-sockets:socket-connect sock socket-path))
(stream (sb-bsd-sockets:socket-make-stream sock :element-type '(unsigned-byte 8) :input t :output t))
(socket (usocket::make-stream-socket :socket sock :stream stream))
(connection (make-instance 'connection
:hostname socket-path
:port 0
:socket socket)))
(declare (ignore _))
(lem-lisp-mode/swank-protocol::setup connection)
connection))))
(add-and-change-connection connection)
(start-thread)
(when start-repl (start-lisp-repl))
(connected-slime-message connection)))


(defun pull-events ()
(when (connected-p)
(handler-case (loop :while (message-waiting-p (current-connection))
Expand Down Expand Up @@ -1116,7 +1129,7 @@
(let* ((port (lem/common/socket:random-available-port))
(process (run-lisp :command command :directory directory :port port)))
(send-swank-create-server process port)
(start-lisp-repl-internal :new-process t)
(start-lisp-repl)
(let ((spinner
(start-loading-spinner :modeline
:buffer (repl-buffer)
Expand Down

0 comments on commit b702fac

Please sign in to comment.